docker service
is the equivalent of docker run
in swarm
If we remove a task/container from the cluster using docker container rm -f <task-name>
then swarm will automatically spin up a new container
Important
- Use the
-d
flag with the service command to start in detached state as we need to wait till the service is deployed- The
-v
flag does not work with service instead we need to use the--mount
flag
Editing most of the properties of the container is got to cause them to be redeployed
The changes are propagated one by one to all the containers to minimize downtime
Docker does not have an option to rebalance tasks on the nodes
Sometimes we can end up in situation where some nodes have a lot of tasks
Docker before deploring a service always checks which node is the best to deploy an task
By forcing an redeployment of an service we can have the nodes utilized in a efficient manner