在/etc/docker/daemon.json 中加入键值对
{
"hosts":["192.168.1.163","unix:///var/run/docker.sock"]
}
docker daemon-reload
systemctl restart docker
vi /etc/systemd/system/docker-tcp.socket
[Unit]
Description=Docker Socket for the API
[Socket]
# ListenStream=127.0.0.1:2375
ListenStream=2375
BindIPv6Only=both
Service=docker.service
[Install]
WantedBy=sockets.target
systemctl daemon-reload
systemctl enable docker-tcp.socket
systemctl stop docker
systemctl start docker-tcp.socket
systemctl start docker
注意:这种方法必须先启动 docker-tcp.socket,再启动 Docker,一定要注意启动顺序!
添加端口
firewall-cmd --permanent --zone=public --add-port=2375/tcp
查看端口列表
firewall-cmd --permanent --zone=public --list-ports
关闭防火墙的命令
systemctl stop firewalld.service
开启防火墙的命令
systemctl start firewalld.service
此时可以通过远端client操作docker(在另一台装有 Docker 的机器上输入命令)
docker -H 192.168.1.163 info
出现以下信息表示连接成功
Containers: 4
Running: 4
Paused: 0
Stopped: 0
Images: 35
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
···
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
http://hub-mirror.c.163.com
Live Restore Enabled: false
一张图搞定,没有安装 IDEA docker 插件的参考上一篇:https://blog.csdn.net/adolph586/article/details/82706987
这样上篇里 3.3.3 设置镜像名和容器名 的 Server 列表里就会有 新加的远程 docker 服务了,其它设置参考上篇,这里不多赘述。