Docker Swarm is a container orchestration tool which allows users to manage multiple containers with ease. With its help containers can be easily deployed across various host machines. Docker swarm offers high level of availability for applications.
Container Orchestration System
If you need to run hundreds of containers a container orchestration system is required. You can easily see that if they are running in a distributed mode, there are multiple features that you will need from a management point of view to make sure that the cluster is up and running without errors.
Some of these necessary features include:
- Health Checks on the Containers
- Launching a fixed set of Containers for a particular Docker image
- Scaling the number of Containers up and down depending on the load
- Performing rolling update of software across containers
Setup a cluster with Docker Swarm
We will use AWS ec2 for setting up the cluster, so we will launch 3 Ubuntu 18.04 machine from AWS marketplace, 1 will be master node and other 2 will be work
Each node must also be running Docker.
Curl -ssl https://get.docker.com | sh
This will install the latest version of Docker engine.
Create Swarm Manager
Run the command below on the manager machine.
sudo docker swarm init –advertise-addr 192.168.0.100
The output will be like:
Save the token from the above output, this will be used to add the nodes to the cluster.
You can see the nodes in the cluster with the command below:
Add Nodes to cluster:
SSh to you worker nodes and install Docker in them.
Then you can join the cluster by entering the token we have saved above with swarm join command.
Run this command in both the nodes.
Then go back to the master node and run the following command to check how many nodes have joined.
Deploy a sample service on cluster.
It will create a service for the nginx web server.
You can list and check the status of the service.
Clustering made easy with Swarm
That’s the gist of creating a Docker swarm and creating a service on your new cluster. To learn more about what Docker swarm can do, issue the command Docker swarm — help to see the other commands you can use for Docker swarm.
If you need help in configuring this cluster, feel free to email us firstname.lastname@example.org or call us at +1 810 214 2572