Creating tasks and services for your applications
The first thing you should know is that we will never schedule containers on a Docker Swarm cluster. We will always run services, which are the minimal deployment units in a Docker Swarm cluster.
Each service is defined by a number of replicas, known in Docker Swarm as tasks. And finally, each task will run one container.
Important note
Docker Swarm is based on Moby’s SwarmKit project, which was designed to run any kind of task cluster-wide (virtual machines, for example). Docker created Docker Swarm by implementing SwarmKit in the orchestrator, but specifically for running containers.
We will use a declarative model to schedule services in our Docker Swarm cluster by setting the desired state for our services. Docker Swarm will take care of their state continuously and take corrective measures in case of any failure to reconcile its state. For example, if the number of running replicas is not correct because one...