Skip to content

Instantly share code, notes, and snippets.

@styblope
Last active December 1, 2023 03:04
Star You must be signed in to star a gist
Embed
What would you like to do?
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
    
  2. Add /etc/systemd/system/docker.service.d/override.conf

     [Service]
     ExecStart=
     ExecStart=/usr/bin/dockerd
    
  3. Reload the systemd daemon:

     systemctl daemon-reload
    
  4. Restart docker:

     systemctl restart docker.service
    
@abel-delafuente
Copy link

abel-delafuente commented Dec 29, 2022

When i try to build the image be means of the BuildImage command, i am getting the

Connect to http://127.0.0.1:2375 [/127.0.0.1] failed: Connection refused: no further information

Apparently Gradle does not make match with the WSL platform IP.

@lalalazero
Copy link

thanks a lot

@KMMehr
Copy link

KMMehr commented Jan 14, 2023

Great job
Thanks

@Sharaf5
Copy link

Sharaf5 commented Jan 14, 2023

@abel-delafuente tcp not http
you could also try to use a unix socket instead and test again to make sure if it's a docker behavior or a network restriction

@KyongSik-Yoon
Copy link

Great! It's working for me.

@djshaw0350
Copy link

Anyone having issues on DietPi? I am just getting familiar with DietPi and cannot get this to work.

@intellectualDarknet
Copy link

that helped thank you!

@lennon101
Copy link

Add /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd

I'm on a Synology NAS and I don't have the folder /etc/systemd/system/docker.service.d/override.conf ??? Any help on how to do step 2?

@My-Random-Thoughts
Copy link

For everyone finding this page and looking for instructions for Synology's new Container Manager,

  1. sudo vi /var/packages/ContainerManager/etc/dockerd.json

change to:
{"data-root":"/var/packages/ContainerManager/var/docker","log-driver":"db","registry-mirrors":[],"storage-driver":"aufs","hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}

(basically add the stuff from the original step 1 to the end, without the curly-brackets {} )

  1. systemctl daemon-reload

  2. sudo systemctl restart pkg-ContainerManager-dockerd

You may need to repeat these steps when the Container Manager package gets updated. So far it's working for me

@honue
Copy link

honue commented Sep 20, 2023

For everyone finding this page and looking for instructions for Synology's new Container Manager,

  1. sudo vi /var/packages/ContainerManager/etc/dockerd.json

change to: {"data-root":"/var/packages/ContainerManager/var/docker","log-driver":"db","registry-mirrors":[],"storage-driver":"aufs","hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}

(basically add the stuff from the original step 1 to the end, without the curly-brackets {} )

  1. systemctl daemon-reload
  2. sudo systemctl restart pkg-ContainerManager-dockerd

You may need to repeat these steps when the Container Manager package gets updated. So far it's working for me

Hi,bro. I'm trying to add the proxy option for the dockerd.json,there is some problem for me.
I had read the docs of how to set the value of daemon-proxy,but the error still exsit.

  "proxies": {
    "http-proxy": "http://proxy.example.com:80",
    "https-proxy": "https://proxy.example.com:443",
    "no-proxy": "*.test.example.com,.example.org",
  }

unable to configure the Docker daemon with file /var/packages/ContainerManager/etc/dockerd.json: the following directives don't match any configuration option: http-proxy, https-proxy, no-proxy

{"data-root":"/var/packages/ContainerManager/var/docker","log-driver":"db","proxies":{"http-proxy":"http://127.0.0.1:7890","https-proxy":"http://127.0.0.1:7890","no-proxy":"localhost,127.0.0.1"},"registry-mirrors":[],"storage-driver":"aufs"}
can you give me some help? appreciate it.

@My-Random-Thoughts
Copy link

Sorry @honue , I don't know as I don't use proxies. Maybe Synology doesn't support those options. They are also using a slightly older version of docker. v20.10.23, build 876964a

@solarsparq
Copy link

ExecStart=
ExecStart=/usr/bin/dockerd --config-file /etc/docker/daemon.json

Thank you. This override.conf trick worked nicely for me. I used daemon.json to supply my TLS configuration as well as listen on 2376. Giving it nothing except a reference to daemon.json feels like a hack to avoid the hosts conflict.. but it works. Thanks again @webzakimbo

root@mnretrogamer029:~# cat /etc/docker/daemon.json
{
"data-root": "/mnt/dietpi_userdata/docker-data",
"log-driver": "journald",
"log-level": "warn",
"debug": false,
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tlscacert": "/etc/docker/certs.d/ca.pem",
"tlscert": "/etc/docker/certs.d/server-cert.pem",
"tlskey": "/etc/docker/certs.d/server-key.pem",
"tlsverify": true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment