For the last six months, the Acme Anvil Corporation has been migrating some of their bare metal infrastructure to Docker containers. A schism has developed between the members of your team on whether to use Docker Swarm or Kubernetes. To settle the dispute, your manager has decided to create a series of challenges. You have been tasked with creating a demo on how to back up and restore a Docker swarm. You are to set up a Docker swarm with 3 nodes, scale the backup service up to 3 nodes, and back up your master node and restore it to a backup instance.
Successfully complete this lab by achieving the following learning objectives:
- Back up the swarm master.
dockerservice on the master node.
systemctl stop docker
Back up the
systemctl stop docker tar czvf swarm.tgz /var/lib/docker/swarm/
- Restore the swarm on the backup master.
Copy the swarm backup from the master node to the backup master:
scp swarm.tar.tgz [email protected]_IP_ADDRESS:/home/cloud_user/
From the backup master, extract the backup file:
tar xzvf swarm.tar.tgz
Copy the swarm directory to
cd /var/lib/docker cp -rf swarm/ /var/lib/docker/
Reinitialize the swarm:
docker swarm init --force-new-cluster
- Add the worker nodes to the restored cluster.
Remove each node from the old swarm:
docker swarm leave
Add each node to the backup swarm:
docker swarm join --token TOKEN IP_ADDRESS:2377
- Distribute the replicas across the swarm.
Scale the replicas down to 1:
docker service scale backup=1
Next, scale the replicas up to 3 to distribute the replicas across the swarm:
docker service scale backup=3