- Lab
- A Cloud Guru
Working with Docker Swarm
The student will be tasked to work with Docker and configure one management node and one client node, with the Docker service running. They will then need to add the client node to a swarm cluster and work with services across the swarm.
Path Info
Table of Contents
-
Challenge
Initialize your Master Node
Before you can create a service, you have to initialize the swarm master. You can accomplish this via:
docker swarm init
NOTE: Be sure to capture the output of the command so that you can use it on your node to register with the master!
-
Challenge
Register Your Node with the Swarm Master
Once the master has been initialized, you will have captured the 'join' command containing the token you need. The command will look something like this. You will run the following command on the second server in your configuration:
docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377
NOTE: Your token string AND IP will differ for your lab, this is an example of the command you will run
-
Challenge
Create the Service in Your Swarm
Be sure you download the image you plan to work with:
docker pull httpd
Now, on the master server, you can run the following command to run your service:
docker service create --name our_api --replicas=2 httpd:latest
This will create a service with two replicas, one running on each node in the swarm
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.