Mar 1, 2018

Making Docker Daemon listen on network port during start-up

Took a bit of time to find the relevant documentation piece, so I thought I would outline it here for easy reference.

Option 1:

This should work for some systems, although distributions that use systemctl may have their docker.service entry overwrite this setting, so you will need to use option 2.
  1. If not already created, create the file /etc/docker/daemon.json
  2. Add in the following:
    
    {
      "hosts": ["fd://", "tcp://0.0.0.0:2375"]
    }
    
  3. Restart docker and check the docker daemon process. It should have the additional -H flag like so:
    
    $ sudo ps aux | grep dockerd
    root     31239  0.7  0.2 1007880 72816 ?       Ssl  15:03   0:00 /usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
    

Option 2:

  1. Edit the service by running:
    
    sudo systemctl edit docker.service
    

  2. Add the following lines:
    
    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
    
  3. Reload the service configuration:
    
    sudo systemctl daemon-reload
  4. Restart the daemon:
    
    sudo systemctl restart docker.service
  5. Use the last step of the previous option to test whether docker is listening on the network port

No comments:

Post a Comment

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!