工作环境为CentOS
- 配置docker daemon启动参数
在 /lib/systemd/system/docker.service中做如下修改
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:5555 -H unix:///var/run/docker.sock
添加参数-H tcp://0.0.0.0:5555 -H unix:///var/run/docker.sock
用来同时打开本地socket和远程端口。
- 允许防火墙开启端口
firewall-cmd --permanent --add-port=5555/tcp
firewall-cmd --reload
- 重新启动docker
service docker reload
- 查看端口状态
[root@localhost system]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 981/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1087/master
tcp6 0 0 :::5555 :::* LISTEN 1654/dockerd
tcp6 0 0 :::22 :::* LISTEN 981/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1087/master
- 远程测试
http://192.168.200.214:5555/v1.29/images/json
v1.29为api版本
本文记录了在CentOS环境下配置Docker daemon,通过添加参数 `-H tcp://0.0.0.0:5555 -H unix:///var/run/docker.sock` 启用远程API和本地socket访问。内容包括允许防火墙开启端口,重启Docker服务,检查端口状态以及进行v1.29 API版本的远程测试。
1959

被折叠的 条评论
为什么被折叠?



