Deploy Container Using Docker Swarm Cluster On Linux

In our previous article, we have installed and configure the docker worker nodes. Now I’m going to deploy the container using docker swarm. You can deploy and check the containers list using the swarm cluster. you can also configure docker swarm container.

Deploy Container Using Docker Swarm On Linux:

Service is also known as a container in a docker swarm. So, I will use the below command to create a container of apache. Docker swarms also act as worker nodes.

Check Out: Create Apache Docker Image Using Dockerfile In Linux

I will deploy 5 replicas of the same container. This will manage where to deploy the container.

docker service create -p 8181:80 --name webserver --replicas 5 httpd

deploy container using docker swarm

With the below command to check the container list.

docker service ls

deploy container to swarm

After a few minutes, you will see 2 containers are created on the docker swarm node and three on the worker nodes.

Check Out: How To Create docker Cluster Using Swarm On Linux

Now check on workers node,

check deployed container

Run the below command to check the status of the webserver,

docker service ps webserver

configure docker swarm cluster

Suppose I have removed one container from worker nodes,

docker rm 3ee7085e7a4b -f

docker swarm multiple managers

Check the status on master nodes, you will see one container is shutdown which I removed for testing.

Check Out: Configure Filebeat For MySQL Database Server In Elasticsearch ELK

docker list stopped containers

Now scale up and down the container using the below command.

docker service scale webserver=8

list of containers docker

Now see docker swarm master scaled up to 8 running containers, equally created 4 containers on itself and worker nodes.

Check Out: LDAP Authentication With Gitlab Server Using Active Directory

You can also check container of apache webserver using below command

docker service ps webserver

That’s it. configure docker swarm cluster docker swarm list containers check deployed container

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment