Open Docker 2375 port, so that the remote host can access

1. View the version information of the remote host Docker

version

docker -H tcp://10.4.7.81:2375 version

Insert picture description here

info

Insert picture description here
As you can see, remote access is not possible, only simple Docker version information can be obtained. If you want to be able to access remotely, you must set it up.

2. Permanently close the firewall of the remote Docker host or open port 2375 (otherwise it will be inaccessible)

systemctl stop firewalld

systemctl disable firewalld

or

sudo firewall-cmd --add-port=2375/tcp --permanent
sudo firewall-cmd --reload

sudo firewall-cmd --list-all   (查看开放可访问的端口)

3. Permanently close SeLinux on the remote Docker host (otherwise it will be inaccessible)

View the status of Selinux:

sestatus

Insert picture description here

Modify file/etc/sysconfig/selinux

Set up SELINUX=disabled

To make the configuration effective, restart the host.

4. Modify /usr/lib/systemd/system/docker.service

Insert picture description here
Modify one of them ExecStart.

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
  • "Unix:///var/run/docker.sock": unix socket, the local client will connect to Docker Daemon through this
  • "Tcp://0.0.0.0:2375": tcp socket, which means that any remote client is allowed to connect to Docker Daemon through port 2375

Execute after modification

systemctl daemon-reload

systemctl restart docker

5. Use Docker remotely

docker -H tcp://10.4.7.81:2375 info

Insert picture description here
As you can see, you can access Docker remotely.

The Docker service on the remote host can also be operated through the Docker Client.

Guess you like

Origin blog.csdn.net/qq_27198345/article/details/112616110