Search code examples
dockerdocker-swarm

Docker daemon not starting after adding the -H flag


I'm trying to use Docker Swarm, to do that I need to start the Docker daemon with the -H flag on each node using this command:

docker -H tcp://0.0.0.0:2375 -d

When doing this on my node (Debian 8, Docker 1.6.0) the command never stops, even if it displays that the daemon has completed initialization.

The complete output:

INFO[0000] +job init_networkdriver()                    
INFO[0000] +job serveapi(tcp://0.0.0.0:2375)            
INFO[0000] Listening for HTTP on tcp (0.0.0.0:2375)     
INFO[0000] /!\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\ 
INFO[0000] -job init_networkdriver() = OK (0)           
WARN[0000] mountpoint for memory not found              
INFO[0000] Loading containers: start.                   
INFO[0000] Loading containers: done.                    
INFO[0000] docker daemon: 1.6.0 4749651; execdriver: native-0.2; graphdriver: aufs 
INFO[0000] +job acceptconnections()                     
INFO[0000] -job acceptconnections() = OK (0)            
INFO[0000] Daemon has completed initialization

After this last line nothing happens and I'm not able to write another command.

I also ran the command using screen to be able to run a command after the first one but I have a error message when running a Docker command:

FATA[0000] Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

This command clearly states that the daemon didn't start correctly. How could I have a Docker daemon that starts and ensures that remote API on Swarm Agents is available over TCP for the Swarm Manager?


Solution

  • This commands states the client cannot talk to the docker daemon/engine/server. According to logs, your server is running.

    With only the -H tcp://0.0.0.0:2375, if you didn't export DOCKER_HOST=127.0.0.1:2375, the docker client won't be able to talk to the daemon. You have 2 ways to handle this :

    1. Exporting DOCKER_HOST

      # Exporting DOCKER_HOST when you want to talk to it
      $ export DOCKER_HOST=127.0.0.1:2375
      $ docker ps
      
    2. Or update your server options to also bind to the socket, like this

      # docker -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock -d
      $ docker ps