docker swarm 集群
docker 集群创建
# 设置主机名方便辨识
# hostnamectl set-hostname node-14
# service docker restart
firewall-cmd --permanent --zone=public --add-port=2377/tcp
firewall-cmd --reload
docker swarm init --advertise-addr 192.168.102.14
添加worker节点
# 设置主机名方便辨识
# hostnamectl set-hostname node-26
# service docker restart
# To add a worker to this swarm, run the following command:
$ docker swarm join --token SWMTKN-1-31ge2fjga4mdisqmq264xzr41x0d0wo3zv10g57f6t7nd96glt-24g1hp3mujr0ydwx8qp4yfwth 192.168.102.14:2377
# To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
添加node lables
添加access_key srecrt_key
docker UI
1.只在管理节点上运行
$ docker service create -d --name Portainer-UI -p 59000:9000 --constraint 'node.role == manager' --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock portainer/portainer-ce:latest
2.全局运行
$ docker service create -d --name Portainer-UI -p 59000:9000 --mode global --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock portainer/portainer-ce:latest
3.进入UI
http://192.168.102.14:59000
设置密码账号密码