for i in 1 2 3; do
docker-machine create -d virtualbox swarm-$i
done
Checking my machines
docker-machine ls
The output is
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
swarm-1 - virtualbox Running tcp://192.168.99.100:2376 v1.13.0
swarm-2 - virtualbox Running tcp://192.168.99.101:2376 v1.13.0
swarm-3 - virtualbox Running tcp://192.168.99.102:2376 v1.13.0
Creating the cluster
eval "$(docker-machine env swarm-1)"
docker swarm init --advertise-addr $(docker-machine ip swarm-1)
eval "$(docker-machine env swarm-1)"
docker service create \
--name=visualizer \
--publish=8000:8080/tcp \
--constraint=node.role==manager \
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
dockersamples/visualizer
open http://$(docker-machine ip swarm-1):8000
eval "$(docker-machine env swarm-1)"
JOIN_TOKEN=$(docker swarm join-token -q worker)
for i in 2 3; do
eval "$(docker-machine env swarm-$i)"
docker swarm join --token $JOIN_TOKEN \
--advertise-addr $(docker-machine ip swarm-$i) \
$(docker-machine ip swarm-1):2377
done
eval "$(docker-machine env swarm-1)"
docker node ls
eval "$(docker-machine env swarm-1)"
docker network create -d overlay routing-mesh
eval "$(docker-machine env swarm-1)"
docker service create \
--name=docker-routing-mesh \
--publish=8080:8080/tcp \
--network routing-mesh \
--reserve-memory 20m \
albertogviana/docker-routing-mesh:1.0.0
curl http://$(docker-machine ip swarm-1):8080
curl http://$(docker-machine ip swarm-2):8080
curl http://$(docker-machine ip swarm-3):8080
docker service scale docker-routing-mesh=3
while true; do curl http://$(docker-machine ip swarm-1):8080; sleep 1; echo "\n"; done
eval "$(docker-machine env swarm-1)"
docker service update \
--update-failure-action pause \
--update-parallelism 1 \
--image albertogviana/docker-routing-mesh:2.0.0 \
docker-routing-mesh
while true; do curl http://$(docker-machine ip swarm-1):8080/health; sleep 1; echo "\n"; done
echo test | docker secret create my_secret -
docker secret ls
eval "$(docker-machine env swarm-1)"
docker service update \
--update-failure-action pause \
--update-parallelism 1 \
--secret-add my_secret \
--image albertogviana/docker-routing-mesh:2.0.0 \
docker-routing-mesh
docker node update --availability=drain swarm-3
docker node ls
docker node update --availability=active swarm-3
docker system info
docker system df
docker system prune