Deploy Containers
To deploy the above file in the docker swarm you need to use the below command:
docker stack deploy my-stack -c docker-compose.yml
Now open the docker desktop to see the 3 running containers.
To check whether container is properly running the nginx image or not, open the web browser and paste the below url:
http://localhost:80
You can also see the list of services currently running using the below command:
docker service ls
If any node fails and one of the above three containers stops, the docker swarm will automatically restart it on some other healthy worker node.
How to Use Docker For Fault Tolerance with Docker Replicas?
Docker is a set of platform-as-a-service products that use OS-level virtualization to deliver software in packages called containers. A cluster of docker engines is called a swarm. Docker Swarm is a cluster management and orchestration feature embedded in the Docker Engine.