Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was trying to configure the Docker daemon port as mentioned in a link:

cat /etc/docker/daemon.json
{
"debug": "true",
"hosts": "tcp://127.0.0.1:5000"
}

# Service docker status
docker stop/waiting
# service docker start
start: Job failed to start

Docker version: 17.04

I enabled the debug logs to check the issue for starting the Docker service and got to know from logs at /var/log/upstart/docker.log:

Waiting for /var/run/docker.sock
unable to configure the Docker daemon with file /etc/docker/daemon.json: json: cannot unmarshal string into Go value of type bool

What is causing the issue for the Docker container to start? Is anything wrong in the configuration file daemon.json?

The issues after suggested changes:

cat /etc/docker/daemon.json
{
"debug": true,
"hosts": "tcp://127.0.0.1:5000"
}

ERROR:

Waiting for /var/run/docker.sock
unable to configure the Docker daemon with file /etc/docker/daemon.json: json: cannot unmarshal string into Go value of type []string

So I changed it to:

cat /etc/docker/daemon.json
{
"debug": true,
"hosts": ["tcp://127.0.0.1:5000"]
}

And the debug log:

# cat /var/log/upstart/docker.log
Waiting for /var/run/docker.sock
time="2017-04-29T21:49:39.082025019+05:30" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting --tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]"
time="2017-04-29T21:49:39.087462580+05:30" level=debug msg="Listener created for HTTP on tcp (127.0.0.1:5000)"
time="2017-04-29T21:49:39.091623380+05:30" level=info msg="libcontainerd: new containerd process, pid: 28412"
DEBU[0000] containerd: read past events                  count=0
DEBU[0000] containerd: supervisor running                cpus=1 memory=3953 runtime=docker-runc runtimeArgs=[] stateDir="/var/run/docker/libcontainerd/containerd"
DEBU[0000] containerd: grpc api on /var/run/docker/libcontainerd/docker-containerd.sock
Waiting for /var/run/docker.sock
time="2017-04-29T21:49:39.594179140+05:30" level=debug msg="libcontainerd: containerd health check returned error: rpc error: code = 14 desc = grpc: the connection is unavailable"
Waiting for /var/run/docker.sock
Waiting for /var/run/docker.sock
time="2017-04-29T21:49:40.093473005+05:30" level=debug msg="libcontainerd: containerd health check returned error: rpc error: code = 14 desc = grpc: the connection is unavailable"
time="2017-04-29T21:49:40.103148602+05:30" level=debug msg="Using default logging driver json-file"
time="2017-04-29T21:49:40.104791557+05:30" level=debug msg="Golang's threads limit set to 56610"
time="2017-04-29T21:49:40.120505279+05:30" level=info msg="[graphdriver] using prior storage driver: aufs"
time="2017-04-29T21:49:40.121399341+05:30" level=debug msg="Using graph driver aufs"
time="2017-04-29T21:49:40.127259410+05:30" level=debug msg="Max Concurrent Downloads: 3"
time="2017-04-29T21:49:40.127366059+05:30" level=debug msg="Max Concurrent Uploads: 5"
time="2017-04-29T21:49:40.139747219+05:30" level=info msg="Graph migration to content-addressability took 0.00 seconds"
time="2017-04-29T21:49:40.140011955+05:30" level=warning msg="Your kernel does not support swap memory limit"
time="2017-04-29T21:49:40.140100084+05:30" level=warning msg="Your kernel does not support cgroup rt period"
time="2017-04-29T21:49:40.140216600+05:30" level=warning msg="Your kernel does not support cgroup rt runtime"
time="2017-04-29T21:49:40.140342372+05:30" level=warning msg="mountpoint for pids not found"
time="2017-04-29T21:49:40.140594173+05:30" level=info msg="Loading containers: start."
time="2017-04-29T21:49:40.141501935+05:30" level=debug msg="Loaded container 0102006e71695802c5f21edbb9dc4776d4c291d28c8db21fbc30144c7ee5ac58"
time="2017-04-29T21:49:40.142853279+05:30" level=debug msg="Loaded container 01c63f92586b3e792b0bcf5c9081126c71ce816ad4d38031e2bd2019ba536461"
time="2017-04-29T21:49:40.143269945+05:30" level=debug msg="Loaded container 0523a71851447b55b18fe3c8e9ac904837bd5062cc237f7cb507a9e4e3cda410"

   ** REMOVED THE CONTAINERS LOADING INFO **

time="2017-04-29T21:49:40.165085939+05:30" level=debug msg="Loaded container ff01985e70fe0d14210c88b768b2ea521d4521d376e5df0e90895533e577b92e"
Waiting for /var/run/docker.sock
time="2017-04-29T21:49:40.289009591+05:30" level=debug msg="Option Experimental: false"
time="2017-04-29T21:49:40.289131532+05:30" level=debug msg="Option DefaultDriver: bridge"
time="2017-04-29T21:49:40.289205442+05:30" level=debug msg="Option DefaultNetwork: bridge"
time="2017-04-29T21:49:40.294576340+05:30" level=info msg="Firewalld running: false"
time="2017-04-29T21:49:40.297766934+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D PREROUTING -m addrtype --dst-type LOCAL -j DOCKER]"
time="2017-04-29T21:49:40.299341976+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D OUTPUT -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER]"
time="2017-04-29T21:49:40.301053126+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D OUTPUT -m addrtype --dst-type LOCAL -j DOCKER]"
time="2017-04-29T21:49:40.302616266+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D PREROUTING]"
time="2017-04-29T21:49:40.304229207+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D OUTPUT]"
time="2017-04-29T21:49:40.305711736+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -F DOCKER]"
time="2017-04-29T21:49:40.307077262+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -X DOCKER]"
time="2017-04-29T21:49:40.308535928+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -F DOCKER]"
time="2017-04-29T21:49:40.309902224+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -X DOCKER]"
time="2017-04-29T21:49:40.311637703+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -F DOCKER-ISOLATION]"
time="2017-04-29T21:49:40.313500303+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -X DOCKER-ISOLATION]"
time="2017-04-29T21:49:40.315093100+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -n -L DOCKER]"
time="2017-04-29T21:49:40.316612016+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -N DOCKER]"
time="2017-04-29T21:49:40.318047831+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -n -L DOCKER]"
time="2017-04-29T21:49:40.319496142+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -n -L DOCKER-ISOLATION]"
time="2017-04-29T21:49:40.320978680+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C DOCKER-ISOLATION -j RETURN]"
time="2017-04-29T21:49:40.322453938+05:30" level=debug msg="/sbin/iptables, [--wait -I DOCKER-ISOLATION -j RETURN]"
time="2017-04-29T21:49:40.327870386+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -C POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE]"
time="2017-04-29T21:49:40.329395686+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -C DOCKER -i docker0 -j RETURN]"
time="2017-04-29T21:49:40.330870634+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -I DOCKER -i docker0 -j RETURN]"
time="2017-04-29T21:49:40.332401751+05:30" level=debug msg="/sbin/iptables, [--wait -D FORWARD -i docker0 -o docker0 -j DROP]"
time="2017-04-29T21:49:40.333933984+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -i docker0 -o docker0 -j ACCEPT]"
time="2017-04-29T21:49:40.335444643+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -i docker0 ! -o docker0 -j ACCEPT]"
time="2017-04-29T21:49:40.337019261+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -C PREROUTING -m addrtype --dst-type LOCAL -j DOCKER]"
time="2017-04-29T21:49:40.338699953+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER]"
time="2017-04-29T21:49:40.340319708+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -C OUTPUT -m addrtype --dst-type LOCAL -j DOCKER ! --dst 127.0.0.0/8]"
time="2017-04-29T21:49:40.342595449+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -A OUTPUT -m addrtype --dst-type LOCAL -j DOCKER ! --dst 127.0.0.0/8]"
time="2017-04-29T21:49:40.344321469+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -j DOCKER]"
time="2017-04-29T21:49:40.345835836+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -j DOCKER]"
time="2017-04-29T21:49:40.347371940+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT]"
time="2017-04-29T21:49:40.348970025+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT]"
time="2017-04-29T21:49:40.350514996+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -j DOCKER-ISOLATION]"
Waiting for /var/run/docker.sock
time="2017-04-29T21:49:40.354889362+05:30" level=debug msg="/sbin/iptables, [--wait -D FORWARD -j DOCKER-ISOLATION]"
time="2017-04-29T21:49:40.356534823+05:30" level=debug msg="/sbin/iptables, [--wait -I FORWARD -j DOCKER-ISOLATION]"
time="2017-04-29T21:49:40.358137686+05:30" level=debug msg="Network (cdd354f) restored"
time="2017-04-29T21:49:40.369466443+05:30" level=debug msg="Allocating IPv4 pools for network bridge (cdd354f255bdc31986952e845957b04baa477ed7362b4b3b7ed606c31850d68a)"
time="2017-04-29T21:49:40.369595546+05:30" level=debug msg="RequestPool(LocalDefault, 172.17.0.0/16, , map[], false)"
time="2017-04-29T21:49:40.369730759+05:30" level=debug msg="RequestAddress(LocalDefault/172.17.0.0/16, 172.17.0.1, map[RequestAddressType:com.docker.network.gateway])"
time="2017-04-29T21:49:40.371387634+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -C POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE]"
time="2017-04-29T21:49:40.373112693+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE]"
time="2017-04-29T21:49:40.374880382+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -C DOCKER -i docker0 -j RETURN]"
time="2017-04-29T21:49:40.376591245+05:30" level=debug msg="/sbin/iptables, [--wait -t nat -D DOCKER -i docker0 -j RETURN]"
time="2017-04-29T21:49:40.378326734+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -i docker0 -o docker0 -j ACCEPT]"
time="2017-04-29T21:49:40.380015825+05:30" level=debug msg="/sbin/iptables, [--wait -D FORWARD -i docker0 -o docker0 -j ACCEPT]"
time="2017-04-29T21:49:40.381638134+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -i docker0 ! -o docker0 -j ACCEPT]"
time="2017-04-29T21:49:40.383258380+05:30" level=debug msg="/sbin/iptables, [--wait -D FORWARD -i docker0 ! -o docker0 -j ACCEPT]"
time="2017-04-29T21:49:40.384970620+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -j DOCKER]"
time="2017-04-29T21:49:40.386558723+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -j DOCKER]"
time="2017-04-29T21:49:40.388624059+05:30" level=debug msg="/sbin/iptables, [--wait -D FORWARD -o docker0 -j DOCKER]"
time="2017-04-29T21:49:40.390622271+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT]"
time="2017-04-29T21:49:40.392615245+05:30" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT]"
time="2017-04-29T21:49:40.394577019+05:30" level=debug msg="/sbin/iptables, [--wait -D FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT]"
time

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
301 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is an addition to the answer provided by Dan Lowe.

There are two ways in configuring the Docker daemon port:

  1. Configuring at /etc/default/docker file:

    DOCKER_OPTS="-H tcp://127.0.0.1:5000 -H unix:///var/run/docker.sock"
    
  2. Configuring at /etc/docker/daemon.json:

    {
    "debug": true,
    "hosts": ["tcp://127.0.0.1:5000", "unix:///var/run/docker.sock"]
    }
    

Restart the Docker service after configuring the port.

If the Docker default socket is not configured, the similar issue mentioned in the question may occur, i.e., Docker will wait for an infinite period.

Note: But don't configure in both the configuration files. The following error may occur:

Waiting for /var/run/docker.sock
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [tcp://127.0.0.1:5000 unix:///var/run/docker.sock], from file: tcp://127.0.0.1:5000)

The reason for adding both the user port[ tcp://127.0.0.1:5000] and default Docker socket[unix:///var/run/docker.sock] is that the user port enables the access to the Docker APIs whereas the default socket enables the CLI. In case the default port[unix:///var/run/docker.sock] is not mentioned in the /etc/default/docker file the following error may occur:

# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

This error is not because that the Docker container is not running, but because the default Docker socket is not enabled.

This is applicable for Docker version 17.04, and it may vary with different versions of Docker.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...