打开docker配置文件
vi /etc/docker/daemon.json
添加hosts项
"hosts":["tcp://0.0.0.0:4243","unix:///var/run/docker.sock"],
"bip": "172.31.254.1/24",
"cluster-store": "etcd://service2.cs-cn-beijing.aliyun-inc.com:2379/c8d2d852b07ce468594deb20af13b20af",
"cluster-store-opts": {
"kv.cacertfile": "/etc/docker/acs-ca.pem",
"kv.certfile": "/etc/docker/agent.pem",
"kv.keyfile": "/etc/docker/agent-key.pem"
},
"cluster-advertise": "eth0:2376",
"labels": [
"provider=aliyunecs",
"aliyun.zone=cn-beijing-d",
"aliyun.instance_id=i-2zeibfbzd6cb6pfazuql",
"aliyun.node=c8d2d852b07ce468594deb20af13b20af-node1",
"aliyun.network_mode=vpc",
"aliyun.region=cn-beijing",
"aliyun.node_index=1",
"aliyun.cluster=c8d2d852b07ce468594deb20af13b20af",
"com.docker.network.driver.overlay.vxlan.port=5789",
"com.docker.network.driver.vpc.subnet=172.18.2.1/24",
"aliyun.tunnel_server=tunnel2-cn-beijing-vpc.aliyun-inc.com:4443"
],
"log-opts": {
"max-size": "10m",
"max-file": "10"
},
"oom-score-adjust": -1000,
"registry-mirrors": ["https://cje4chc8.cn-beijing.mirror-vpc.aliyuncs.com"],
"storage-driver": "overlay"
}
参数permanent表示永久开启端口,不然重启失效
firewall-cmd --zone=public --add-port=2375/tcp --permanen
重启
firewall-cmd --reload
重启docker
systemctl restart docker
测试
用其他机器访问docker api
docker -H 59.110.229.202:2375 images