Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
PS:
- physical ip address native localhost
1. Download and zookeeper swarm Mirror Mirror
docker pull swarm
docker pull zookeeper
2. modify the configuration docker Configuration
- Find the profile path
[hadoop001@dhc-slaver1 ~]$ systemctl status docker.service
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
- Modify the configuration file
vim /usr/lib/systemd/system/docker.service
在ExecStart行后添加
-H 0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=zk://172.16.125.128:2181 --cluster-advertise=localhost:2375
- Reload the configuration and reboot
systemctl daemon-reload
systemctl restart docker.service
3. Create a zookeeper container
docker run --name some-zookeeper --restart always -d zookeeper
4. Create a swarm agent
docker run --name swarm-agent1 -d swarm join zk://172.16.125.128:2181/swarm-agent --addr=localhost:2375
5. Create a swarm manager
docker run --name swarm-manage -d -p 2376:2375 swarm manage zk://172.16.125.128:2181/swarm-agent
6. Check operation
docker -H tcp://localhost:2380 ps
7. Create a network on manager
docker network create --driver overlay n_net
8. Check the network created situation
- On all machines swarm cluster
docker network ls