docker-machine create -d virtualbox manager
for i in 1 2; do
docker-machine create -d virtualbox worker-$i
done
Checking my machines
docker-machine ls
Creating the cluster
eval "$(docker-machine env manager)"
docker swarm init --advertise-addr $(docker-machine ip manager)
eval "$(docker-machine env manager)"
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 \
--detach=false \
dockersamples/visualizer
explorer http://$(docker-machine ip manager):8000
eval "$(docker-machine env manager)"
JOIN_TOKEN=$(docker swarm join-token -q worker)
for i in 1 2; do
eval "$(docker-machine env worker-$i)"
docker swarm join --token $JOIN_TOKEN \
--advertise-addr $(docker-machine ip worker-$i) \
$(docker-machine ip manager):2377
done
eval "$(docker-machine env manager)"
docker node ls
eval "$(docker-machine env manager)"
docker network create -d overlay routing-mesh
eval "$(docker-machine env manager)"
docker service create \
--name=docker-routing-mesh \
--publish=8080:8080/tcp \
--network routing-mesh \
--reserve-memory 20m \
lanovoy/docker-swarm-presentation:1.0
curl http://$(docker-machine ip manager):8080
curl http://$(docker-machine ip worker-1):8080
curl http://$(docker-machine ip worker-2):8080
docker service scale docker-routing-mesh=3
while true; do curl http://$(docker-machine ip manager):8080; sleep 1; printf "\n"; done
eval "$(docker-machine env manager)"
docker service update \
--update-failure-action pause \
--update-parallelism 1 \
--image lanovoy/docker-swarm-presentation:2.0 \
docker-routing-mesh
while true; do curl http://$(docker-machine ip manager):8080/health; sleep 1; printf "\n"; done
docker-machine.exe ssh manager
echo my-very-secret-value | docker secret create my_secret -
docker secret ls
eval "$(docker-machine env manager)"
docker service update \
--update-failure-action pause \
--update-parallelism 1 \
--secret-add my_secret \
--image lanovoy/docker-swarm-presentation:2.0 \
docker-routing-mesh
curl http://$(docker-machine ip manager):8080
docker exec $(docker ps --filter name=docker-routing-mesh -q) ls -l /run/secrets
docker node update --availability=drain worker-2
while true; do curl http://$(docker-machine ip manager):8080/health; sleep 1; printf "\n"; done
docker node ls
docker node update --availability=active worker-2