- 在本地三台服务器上搭建docker 集群
- docker run hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
** 原因**: 为正确启动服务:
systemctl daemon-reload
sudo service docker restart
sudo service docker status
sudo docker run hello-world
重启后正常.
-
分别在三台服务器启动docker 服务
-
docker pull swarm
-
防火墙
firewall -cmd --state
//查看防火墙状态
systemctl stop firewalld
// 关闭防火墙
systemctl start firewalld
//开启防火墙
systemctl disable firewalld
//禁止防火墙开机启动 -
启动swarm
docker swarm init --advertise-addr 192.168.1.1 --listen-addr 192.168.1.1:2377
docker swarm init --advertise-addr 192.168.1.2 --listen-addr 192.168.1.2:2377
docker swarm init --advertise-addr 192.168.1.3 --listen-addr 192.168.1.3:2377
1.初始化
docker swarm init --advertise-addr 192.168.1.1
[bonc@pingxiaogang08 ~]$ docker swarm init --advertise-addr 192.168.70.8
Swarm initialized: current node (s4t47u5w1gmf5y7ae7uothcwp) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-1q5e26n88kr47ccaiswzf4enc6trhqm07y5demu33d9thugun7-0we1tt941r9fj1nxoga97cw8d 192.168.70.8:2377
To add a manager to this swarm, run ‘docker swarm join-token manager’ and follow the instructions.
2.添加节点
docker swarm join --token SWMTKN-1-1q5e26n88kr47ccaiswzf4enc6trhqm07y5demu33d9thugun7-0we1tt941r9fj1nxoga97cw8d 192.168.70.8:2377
- 完成