-
This workshop require student to install Virtualbox on their host machine the OS can be either Windows 10/Macos/Linux
-
MacOS users require to install brew (https://brew.sh/)
brew cask install virtualbox
- Create docker machines ( to act as nodes for Docker Swarm), one manager as 'namager1 and two workers as 'worker1' and worker2'
$ docker-machine create --driver virtualbox manager1
$ docker-machine create --driver virtualbox worker1
$ docker-machine create --driver virtualbox worker2
- Verify machine created successfully
docker-machine ls
docker-machine ip <machine name>
- Initialize the Docker Swarm
docker swarm init --advertise-addr MANAGER_IP
- Connect to the machine via SSH
docker-machine ssh <machine name>
- Upon ssh into the manager machine, list all the current nodes connected to the swarm
docker node ls
- In order to retrieve the join as worker command in the manager machine run the below command
docker swarm join-token worker1
- In the manager machine run the below command, to check on the swarm info
docker info
docker swarm
- Run containers on the Docker Swarm
docker service create --replicas 3 -p 80:80 --name serviceName nginx
Verify the status of the swarm
docker service ls
docker service ps serviceName
- Scaling service up and down
docker service scale serviceName=2
- Inspecting the nodes (this command can only run on the manager node)
docker node inspect nodename
docker node inspect self
docker node inspect worker1
- In order to shutdown the nodes (Inside the manager nodes)
docker node update --availability drain worker1/worker2
- To update the services perform the following command
docker service update --image imagename:version web
docker service update --image nginx:1.14.0 serviceName
- Remove services from the swarm
docker service rm serviceName
- Leaving the swarm , stopping and deleting from the swarm
docker swarm leave
docker-machine stop machineName
docker-machine rm machineName