Skip to content

Opening Docker to TCP connections

This is the best way i have found to configure docker on my linux boxes to open them up for tcp connections - the tcp connections are used for Portainer to connect to them. I did no do any security, everything is behind a good firewall.

Instructions

The command systemctl edit is used to change the launch parameters of the docker service.

  1. Edit the docker service
       > sudo systemctl edit docker
    
  2. In the editor, past in the following
       [Service]
       ExecStart=
       ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
    
    Save the file and exit the editor.
  3. Restart docker
        > sudo systemctl restart docker
    
  4. Check docker is running with new parameters
        > pgrep -a docker
        21239 /usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
    

Configure Portainer

  1. Login to your portianer instance.
  2. Click on Environments.
  3. Click on +Add Environment.
  4. Choose Docker for Environment Type.
  5. Enter a name for the environment in Name under Environment Details.
  6. Enter hostname:2375 under Environment URL, where hostname is the hostname of the docker instance.
  7. Click +Add environment.
Back to top