The Docker Swarm platform in MedStack Control
At the highest level, your MedStack Control environment is divided into clusters. A cluster contains hardware, networks, and nodes (virtual machines).
Running on the cluster and nodes is a Docker swarm, which consists primarily of services, tasks, and containers. Each service is a definition of the containers you want to have running on the swarm. The service has a Docker image that it will use to create containers and some other configuration. Once created, the service will then start one or more tasks. Each task will then attempt to run a container in the appropriate place. Once the container is running, it behaves like any other Docker container.
When you create a cluster in MedStack Control, a Docker swarm is automatically created and runs on the cluster. Some of the nodes are manager nodes, which run the swarm software, and all of the nodes are workers, which run containers. For more information on Docker Swarm, see https://github.com/docker/swarm.
The following example has a cluster with two node virtual machines (#1 and #2). Running on the cluster is a swarm with two services (A and B):
- Service A is configured to run just one container, and so task A1 is running container A1 on the first node.
- Service B is configured to have two replicas, so there are two tasks running two containers.
- The configs and secrets also live in the swarm, residing on the manager nodes, which in this case would be node #1.
Other key concepts you should understand include:
- Services create tasks to run containers. Services have a flexible system to run one or more containers on one or more nodes. By default, a service will run a single container on a single node. A service can also be configured to run multiple containers using “replicas”, and to control what nodes the container(s) run on using service constraints. Each task represents an attempt by the service to run an individual container, whether or not that attempt succeeds. The service will always attempt to make the set of running containers match the replication and service constraints you have specified, using tasks. For more information, see https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/.
- Volumes are used to persist data and to share data between containers that are on the same node. Volumes are connected to containers (not services). Each container has one or more volumes which exist on the node that the container is running on. For more information, see https://docs.docker.com/storage/volumes/.
IMPORTANT If a container needs to move to another node, the container is destroyed and a new one is created. This means that all of the associated volume data is lost. New volumes are created for the container from scratch.
- Configs store configuration files and other non-sensitive information. For more information, see https://docs.docker.com/engine/swarm/configs/.
- Secrets store confidential information such as passwords, SSH private keys or SSL certifications. For more information, see https://docs.docker.com/engine/swarm/secrets/.