If you are coming here from part 2 of the series you will recognize the setup here.
Our current status at the end of part 2 is we have 3 nodes running CentOS and Docker in
Step 1: SSH/Putty into node-1 and initialize Swarm
docker swarm init
Take note of the token that is displayed after you run the init command
Step 2: Investigate your new Swarm
You now have a Swarm with a single node. As it is the first and only
docker info
Step 3: Add "worker nodes" to the Swarm
From the command line on the leader manager node-1 run the command "docker
docker swarm join-token worker
After you have run the command on both node-2 and node-3, go back to leader manager node 1 and run the command
docker node ls
You will notice that the manager leader is still node
Step 4: Create a Nginx "service"
You now have a working Swarm and lets put it to good use. On your leader manager
docker service create --replicas 3 --name nginx --publish 8080:80 nginx
This will create one nginx container on each available node. In our
docker serivce ls
Step 5: Connect to your default Nginx page
What is running on the each of the containers is a simple web server with a default landing page that should be able to access publicly.To do this we will need a few things.First, find out the port that is serving the web page from on the host ( not the container ) we can see that it is 8080.
Open the Azure console and from all resources Icon, search for "
open the node-1 network security group (docker-node-1-
Add an inbound rule that allows port 8080 on the host to be accessed from the public internet. Save the rule.
Repeat adding this rule for node-2 and node-3.
Now we can connect on the Public IP ( the same IP you are ssh-ing on ) and the ports that we know is 8080
so open a browser to <public-ip>:8080
you now have a working web server scaled across the swarm, you should be able to get the Nginx welcome page on all 3 nodes IP and port 8080.
To remove all of this simply delete the Resource Group
I hope you have enjoyed this post and were able to take away some new skills. To become an expert in Docker sign up for one of our awesome classes today!