System version:
Debian 8.3
Problem: The remote API that adds Dcoker under Debian does not always open the network port.
Process:
Modify/etc/default/docker to add a row
docker_opts= "-H 0.0.0.0:2376-h unix:///var/run/docker.sock"
To restart Docker:
Service Docker restart
To see if the port is open:
lsof-i:2376 does not have any return.
To view logs:
Mar 12:44:32 docker1 docker[3491]: time= "2016-03-28t12:44:32.665294330-04:00" Level=info msg= "[Graphdriver] using Prior storage driver \ "Aufs\" "
Mar 12:44:32 docker1 docker[3491]: time= "2016-03-28t12:44:32.667332848-04:00" Level=info msg= "Graph migration to Content-addressability took 0.00 seconds "
Mar 12:44:32 docker1 docker[3491]: time= "2016-03-28t12:44:32.673179732-04:00" Level=info msg= "Firewalld running: False
Mar 12:44:34 docker1 docker[3491]: time= "2016-03-28t12:44:34.908750963-04:00" Level=info msg= "Default Bridge ( DOCKER0) is assigned with an IP address 172.17.0.0/16. Daemon option--bip can be used to set a preferred IP address "
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.035544113-04:00" level=warning msg= "Your kernel does not Support Cgroup memory limit:mountpoint for memory not found "
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.035820306-04:00" level=warning msg= "Your kernel does not Support Cgroup CFS period "
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.035864016-04:00" level=warning msg= "Your kernel does not Support Cgroup CFS quotas "
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.037271326-04:00" Level=info msg= "Loading containers: Start. "
Mar 12:44:36 docker1 docker[3491]:.
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.039178384-04:00" Level=info msg= "Loading containers: Done. "
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.039227903-04:00" Level=info msg= "Daemon has completed Initialization "
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.039262276-04:00" Level=info msg= "Docker daemon" commit= 20F81DD execdriver=native-0.2 Graphdriver=aufs version=1.10.3
Mar 12:44:36 docker1 docker[3491]: time= "2016-03-28t12:44:36.059353006-04:00" Level=info msg= "API Listen on/var/ Run/docker.sock"
Visible no error reported, just opened the/var/run/docker.sock, did not open 2376 port.
Then troubleshoot the problem.
[Email protected]:/var/log#/etc/init.d/docker Stop
[OK] Stopping Docker (via Systemctl): Docker.service.
[Email protected]:/var/log# ps-ef |grep Docker
Avahi 484 1 0 07:23? 00:00:00 avahi-daemon:running
Root 3723 2314 0 12:53 pts/1 00:00:00 grep Docker
[Email protected]:/var/log# bash-x/etc/init.d/docker Start
+ SET-E
+ Export Path=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+ Path=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+ Base=docker
。。。。。。 Omit part
+ . /lib/lsb/init-functions
+ + + run-parts--lsbsysinit--list/lib/lsb/init-functions.d
+ + for hooks in ' $ (run-parts--lsbsysinit--list/lib/lsb/init-functions.d 2>/dev/null) '
+ + ' ['-r/lib/lsb/init-functions.d/20-left-info-blocks '] '
++ . /lib/lsb/init-functions.d/20-left-info-blocks
+ + for hooks in ' $ (run-parts--lsbsysinit--list/lib/lsb/init-functions.d 2>/dev/null) '
+ + ' ['-r/lib/lsb/init-functions.d/40-systemd '] '
+ + ./lib/lsb/init-functions.d/40-systemd
+ + _use_systemctl=0
。。。。。。 Omit part
+ + + ' [' Xstart = xstart-o Xstart = xstop-o Xstart = xrestart-o Xstart = xreload-o Xstart = Xforce-reload-o Xstart = x Status '] '
+ + + systemctl_redirect/etc/init.d/docker start
+ + + log_daemon_msg ' starting Docker (via Systemctl) ' Docker.service
+ + + ' ['-Z ' starting Docker (via Systemctl) '] '
+ + + Log_daemon_msg_pre ' starting Docker (via Systemctl) ' Docker.service
。。。。。。 Omit part
[....] + + + ' ['-Z docker.service '] '
+ + + echo-n ' starting Docker (via Systemctl): Docker.service '
Starting Docker (via Systemctl): docker.service+++ log_daemon_msg_post ' starting Docker (via Systemctl) ' Docker.service
。。。。。。 Omitted
See here the time to understand, have not yet executed to the following start module, the service is Systemctl service took over, set parameters will not take effect.
Take a look at Docker:
[Email protected]:/var/log# ps-ef |grep Docker
Avahi 484 1 0 07:23? 00:00:00 avahi-daemon:running
Root 3741 1 0 12:56? 00:00:00/usr/bin/docker daemon-h fd://
Root 3816 2314 0 13:03 pts/1 00:00:00 grep Docker
The docker_opts parameter is not actually loaded:
Simply do the setup and move the 40-systemd script.
[Email protected]:/var/log#/etc/init.d/docker Stop
[Email protected]:/var/log# mv/lib/lsb/init-functions.d/40-systemd/lib/lsb/
Start Docker
Starting Docker: [email protected]:/var/log#/etc/init.d/docker Start
Take a look
[Email protected]:/var/log# ps-ef |grep Docker
Avahi 484 1 0 07:23? 00:00:00 avahi-daemon:running [docker1.local]
Root 3970 1 0 13:06? 00:00:00/usr/bin/docker daemon-p/var/run/docker.pid-h docker1.y7tech.cn:2376 -H unix:///var/run/ Docker.sock
Root 4080 2314 0 13:07 pts/1 00:00:00 grep Docker
[Email protected]:/var/log# lsof-i:2376
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Docker 3970 root 6u IPv4 20313 0t0 TCP docker1.y7tech.cn:2376 (LISTEN)
Haha, see, the port is open ... Then call it remotely.
[Email protected]:/etc# docker-h docker1.y7tech.cn:2376 Images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.12.138:5000/mongodb v1.0 a9e3f0081258 less than a second ago 408.8 MB
Debian latest f50f9524513f 3 weeks ago 125.1 MB
And see if the local is normal.
[Email protected]:~$ Docker PS
Cannot connect to the Docker daemon. Is the Docker daemon running on this host?
Oh,mygod, there is a local problem.
We can see that/var/run/docker.socket does exist.
[Email protected]:~$ docker-h unix:///var/run/docker.sock Images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.12.138:5000/mongodb v1.0 a9e3f0081258 7 hours ago 408.8 MB
Debian latest f50f9524513f 3 weeks ago 125.1 MB
It's stupid to execute a command like this ... Check out Docker's help to see if there's any good way to do it.
Http://www.simapple.com/274.html
Daemon Field
To edit the local configuration file:
/etc/profile, adding variables
Export docker_host=tcp://docker1.y7tech.cn:2376
Or:
Export Docker_host=unix:///var/run/docker.sock
[Email protected]:~$ Docker ps-a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
The ok! is normal.
Debian fails to open remote API under Docker