Need help dockerize an apt-cacher-ng service

2019-08-29 16:49发布

问题:

I'm following

Dockerize an apt-cacher-ng service
https://docs.docker.com/engine/examples/apt-cacher-ng/

but failed to get it up and running.

I've successfully followed to

To see the logfiles that are tailed in the default command, you can use:

$ docker logs -f test_apt_cacher_ng

and I get

$ docker logs -f test_apt_cacher_ng
WARNING: No configuration was read from file:sfnet_mirrors
Starting apt-cacher-ng: apt-cacher-ng.

But that's as far as I can go and can't go any further. I think my step:

$ docker run -d -p 3142:3142 --name test_apt_cacher_ng eg_apt_cacher_ng

does not give me an apt_cacher_ng at port 3142, because:

$ ip a s | grep 'docker0$'
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0

$ nc -z 172.17.0.1 3142 | wc        
      0       0       0

$ lsof -i :3142 | wc
      0       0       0

What else can I check to make sure I've got a dockerized apt-cacher-ng service, and it is also up and running?

回答1:

Networking is more complicated, because container is running in own network namespace. See listenings:

$ netstat -tanp  | grep 3142
tcp        0      0 172.17.0.1:39182        172.17.0.1:3142         TIME_WAIT   -
tcp6       0      0 :::3142                 :::*                    LISTEN      46336/docker-proxy

The best option will be to check from host OS (apt-cacher-ng is exposed on all interfaces on the port 3142) with curl:

$ curl http://127.0.0.1:3142
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="X-UA-Compatible" content="IE=8" />
      <meta name="MSSmartTagsPreventParsing" content="true" />
      <title>Not Found or APT Reconfiguration required</title>
      <link rel="stylesheet" type="text/css" href="/style.css" />
   </head>
...