-
-
Save piotrplenik/b39e11521452129af2af85cc855c91d7 to your computer and use it in GitHub Desktop.
# File: etc/default/docker | |
# Use DOCKER_OPTS to modify the daemon startup options. | |
#DOCKER_OPTS="" | |
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock" |
# File: /lib/systemd/system/docker.service | |
## Add EnviromentFile + add "$DOCKER_OPTS" at end of ExecStart | |
## After change exec "systemctl daemon-reload" | |
EnvironmentFile=/etc/default/docker | |
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS |
after I exec "systemctl daemon-reload", I still have the 2375 port closed.
$ nmap -p 2375 localhost
Starting Nmap 7.01 ( https://nmap.org ) at 2017-09-20 16:58 HKT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00048s latency).
PORT STATE SERVICE
2375/tcp closed docker
But later after I restart the machine, I found it opened again.
Just landed here while researching the exact same topic.
It's not enough to execute systemctl daemon-reload
(according to its manpage), as it only reloads systemctl's configuration but running services remain untouched. However, I recognized that executing systemctl restart docker
seems to be sufficient to make dockerd listen on the TCP port.
An another note: At least for 16.04, the service description (docker.service) already takes the DOCKER_OPTS defined in /etc/default/docker into account. It's therefore not necessary to change /lib/systemd/system/docker.service
Cannot work well using the method above; but I find another Blog and it fixed my problem: https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
Cannot work well using the method above; but I find another Blog and it fixed my problem: https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
It works, but why IPv6?
In summary, you need to edit the file: /lib/systemd/system/docker.service
Instead of: tcp://127.0.0.1:2375
, use the host IP address, for example: tcp://192.168.1.100:2375
.
Then execute:
systemctl daemon-reload
systemctl restart docker
Remember that setting remote access is not recommended, as someone could gain root access to the host.
Manual base on moby/moby#25357