Skip to content

Instantly share code, notes, and snippets.

@mkfares
Last active August 12, 2020 11:10
Show Gist options
  • Save mkfares/2e41817bdd679246a0f419fa26347e73 to your computer and use it in GitHub Desktop.
Save mkfares/2e41817bdd679246a0f419fa26347e73 to your computer and use it in GitHub Desktop.
Docker Swarm - Definitions

Docker Swarm - Definitions

A swarm is a collection of docker hosts that collaborate together to execute containers. The docker engine is installed on each host of the swarm.

The hosts in the swarm are called nodes. The nodes may run on physical computers or virtual machines. These nodes can play the role of manager, worker or both roles.

The managers are nodes that manage, coordinate and delegate services to nodes. On the other hand, workers are nodes that execute containers. By default, all managers are also workers.

A service is a desired state of a container. The state is defined as number of replicas, network and storage resources available to the service, ports the service exposes to the outside world, and other information. Docker services are managed using the docker service command.

A task is a running container that is defined by a service. It is considered as the atomic scheduling unit of a swarm. Tasks are managed by the swarm manager and executed on workers. A user cannot manage the tasks directly.

A stack manages one or mores services in a swarm. A swarm may have multiple stacks. A stack is used to manage an application that includes multiple services. The stack is defined using the docker compose file.

A swarm manager provides a load balancer that distributes requests among services and exposes service ports to the outside world.

A swarm includes a DNS server which assigns names to services. These names are used in applications to access services such as databases and APIs.

The docker swarm does not need a separate software since it is automatically installed when docker engine is installed on your machine.

The docker swarm has many advantages over docker compose:

  • Docker swarm management is part of the docker engine. The management of the entire cluster is performed on one of the swarm managers.
  • Docker swarm uses the docker-compose file and dockerfile to configure services and create containers (tasks).
  • The number of tasks can be scaled up or down automatically by the swarm manager.
  • Docker swarm creates an overlay network that spans all the nodes in a swarm.
  • Services are incrementally updated to avoid application down time. The performed updates can be rolled back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment