Difficulty: Beginner
Estimated Time: 10 minutes

In this scenario, you will learn how to put a Docker Swarm Mode worker node into maintenance mode. By putting a node into maintenance mode, all existing workloads will be restarted on other servers to ensure availability, and no new workloads will be started on the node.

Maintenance mode allows you to perform operations such as security updates or rebooting machines without the loss of availability.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Putting Nodes into Maintenance Mode

Step 1 of 4

Step 1: Create Swarm Cluster

By default, Docker works as an isolated single-node. All containers are only deployed onto the engine. Swarm Mode turns it into a multi-host cluster-aware engine.

Task: Initialise Swarm Mode

To use the secrets functionality, Docker has to be in "Swarm Mode". This is enabled via docker swarm init

Join Swarm Mode

Execute the command below on the second host to add it as a worker to the cluster.

token=$(docker -H [[HOST_IP]]:2345 swarm join-token -q worker) && docker swarm join [[HOST_IP]]:2377 --token $token

Terminal Host 2