Ana içeriğe geç
Version: 1.6.0

Docker Swarm

After you've decentralized your Database and Storage, you can go into Docker Swarm. If you haven't done so make sure to that first.

Even though you can use Docker Swarm to deploy the application containers as the MariaDB, for example, in this tutorial, you'll go with a decentralized approach for the volumes and the applications.

Good to know

All the docker-compose.yml and .env files are available in the repo.


What Docker Swarm is?

The best way to understand Docker Swarm is to think of it as Docker way to treat a bunch of servers as one giant computer. Meaning you're not creating containers rather services. Each service have tasks which are the actual deployed container.

Docker Swarm has many pieces, here is the must-know terminology:

TerminologyMeaning
NodePhysical server
Manager nodeServer that ranked as a manager. Can change the deployed services and remove other nodes.
Worker nodeServer that ranked as a worker. This server can't change anything rather just get a new tasks for a manager.
StackList of services inside docker-compose.yml file
ServiceDeclaration of a desired state for a given container.
TaskAn action that being send from the managers to a worker contain container details that need to run by the worker.
ReplicaNumber of replicas a given server will have in the Swarm. All the replicas can be in a single node, or they can be scattered all around.
ScalingChanging the number of replicas for a given service in realtime.
Rolling updateChanging the image version (upgrade or downgrade) of a service in realtime.
QuorumIn case of more than one manager, you'll need to have the majority of the managers available before rolling any update. For example, in case you have 3 managers and 2 are down, you won't be able to roll any update. The reason is that the manager need to "consult" each other to come to a verdict before changing some of the settings, To make sure the decision made by you Docker Swarm require you to have the majority of the manager quorum available

For example, if a worker node is not responding is in charge of 3 tasks for some service. The managers will deploy that 3 tasks to other nodes.

Manage nodes

To get a list of all available nodes and their status in the Swarm, run:

docker node ls