Setting Up Docker Swarm

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

After years of running containers on a single Docker host, you’ve decided to migrate over to using Docker Swarm. Using Swarm will allow your clients to scale the number of containers up, as demand increases, and then down as demand dies off.

Before you can do this, you first need to set up a Swarm cluster consisting of a manager and a worker node. Once setup is complete, create an Nginx service to test the cluster.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Initialize the Swarm

On the manager node, initialize the swarm:

[cloud_user@manager]$ docker swarm init 
--advertise-addr [MANAGER_PRIVATE_IP]
Add the Worker to the Cluster

Add the worker to the cluster:

[cloud_user@worker]$ docker swarm join --token [TOKEN] 
[MANAGER_PRIVATE_IP]:2377
Create a Swarm Service

Create nginx_service:

[cloud_user@master]$ docker service create -d --name nginx_service -p 8080:80 --replicas 2 nginx:latest

Additional Resources

Setting up the Swarm:

Login to your Swarm manager and initialize the swarm. Use the advertise-addr flag and supply the private IP of the manager.

Use the join command that gets generated, and have the worker node join the swarm.

Test the swarm by listing the nodes.

Create a Service:

Create an Nginx service that runs in the background.
Name it nginx_service.
Publish port 8080 on the host to port 80 on the container.
Make sure that the service has two replicas.
Make sure to user the latest image of Nginx.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!