How to setup simple Docker Swarm Clustering with visual tools

How to setup simple Docker Swarm Clustering

1. Create 3 docker machines

docker-machine create -d virtualbox --engine-registry-mirror http://8ff28fe8.m.daocloud.io vm1
docker-machine create -d virtualbox --engine-registry-mirror http://8ff28fe8.m.daocloud.io vm2
docker-machine create -d virtualbox --engine-registry-mirror http://8ff28fe8.m.daocloud.io vm3


2. Enter vm1 and config it as manager

docker machine-ssh vm1
docker swarm  init --advertise-addr 192.168.99.101


3. Config vm2 & vm3 as worker

docker-machine ssh vm2
docker swarm join --token SWMTKN-1-3yelia5oyyxc8pn1z9tfb4a8j0liud5tljenquywu6ygiv7fk5-49xmnelykqja5fvft3bp
2892o 192.168.99.101:2377
docker-machine ssh vm3
docker swarm join --token SWMTKN-1-3yelia5oyyxc8pn1z9tfb4a8j0liud5tljenquywu6ygiv7fk5-49xmnelykqja5fvft3bp
2892o 192.168.99.101:2377

4. Create Nginx service as an example

docker service create --name=my_nginx nginx


5. Publish nginx 80 port

docker service update --publish-add 80 my_nginx

Then, you will see following page after accessing any server in the clustering with the port 3000, such as 

http://192.168.99.101:30000/ 

http://192.168.99.102:30000/ 

http://192.168.99.103:30000/ 


6. Scaling replicas

docker service scale my_nginx=5

docker service ps my_nginx


7. Install & config Docker Swarm Clustering visual tookkit (dockersamples/visualizer and Portainer)

7.1 Install dockersamples/visualizer

docker service create --name=viz --publish=8080:8080/tcp --constraint=node.role==manager --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock dockersamples/visualizer
http://192.168.99.101:8080

7.2 Install Portainer

docker service create \
    --name portainer \
    --publish 9000:9000 \
    --constraint 'node.role == manager' \
    --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock \
    portainer/portainer \
    -H unix:///var/run/docker.sock

http://192.168.99.101:9000


猜你喜欢

转载自blog.csdn.net/yexianyi/article/details/80082353