Setup a Docker Swarm in Docker Playground in X mins
get your playground ready
Connect to docker playground with your favorite web browser by surfing URL: http://labs.play-with-docker.com/
Step 1, click on “Create Session” button, after confirm you are a human.
You will see add page to claim your free instances (nodes) as follow;
Click on [+ADD NEW INSTANCE], you can keep adding instances to your playground for up to 5 nodes. Each nodes have up to 8 CPUs and 64 GB of RAM. I’m not sure how long it will keep available for trial.
After you click on that button, you may see a terminal on some node with docker installed in a second as follow; so that you can start to issue docker command or even other linux command in the console.
For example you can try
docker version
to see the current docker version on the node.
Now, we start to create a docker swarm master
If your node1 IP shows 10.0.15.3, and node2 IP shows 10.0.15.4 for example.
You can create a docker swarm master on 10.0.15.3 by using following command,
docker swarm init --advertise-addr 10.0.15.3
Then cut and paste following command, show in your master node console to the second node you added from [+ ADD NEW INSTANCE].
This is my example, you have to use yours token and your master node IP (here is 10.0.15.3)
docker swarm join --token SWMTKN-1-5t75eugx0u471q585kbf5tsl7rekuuhtrsdzzubvq8bn8xpuhk-1x0xscedca5odgxz77muu0f6w 10.0.15.3:2377
So you can see the second node is added to the swarm.
You can test how many nodes are in your docker swarm by using following command in your master node console.
docker node ls
It’s done. I think X is smaller than 5.
Next episode will shows you how to manage your docker swarm with portainer with a awesome web GUI, not just using CLI in consoles.
reference: https://docs.docker.com/engine/swarm/swarm-tutorial/add-nodes/