liveBook · Manning

Docker Swarm stack

As explained in Road to Kubernetes

A Docker Swarm Stack is a deployable group of containerized services defined by a Compose-format configuration for Swarm.

A Docker Swarm stack is a deployable collection of services defined in a Docker Compose-format file. The Swarm manager schedules its services as tasks across worker nodes in a cluster. section 9.1

Use the Swarm vocabulary to understand the deployment:

  • A manager node manages the cluster and tells worker nodes what to run. section 9.1
  • A task is a running container, while a service defines the task to execute. section 9.1
  • A stack groups multiple services under a name and deploys them to the Swarm cluster. section 9.1

Deploy and inspect a stack

From a Swarm manager, run `docker stack deploy -c compose-swarm.yaml rk8s`. List deployed stacks with `docker stack ls`, inspect its running tasks with `docker stack ps rk8s`, and remove it with `docker stack rm rk8s`. Visiting any cluster machine’s public IP can show the same application results as Docker Compose, with more service instances. section 9.1.4

To change a deployed stack, edit `compose-swarm.yaml` and run the deployment command again. Swarm updates only the services that changed. section 9.1.4

Figure 9.3 Docker Swarm Stack deployment output

Deployment output provides a visual reference for launching a named stack from a Compose file. section 9.1.4

How Road to Kubernetes covers it

How deep it goes
Defines nodes, tasks, services, and stacks, then demonstrates deployment, inspection, removal, and incremental updates.
Examples
Uses a swarm-ready Compose file, the `rk8s` stack, three nodes, and Docker stack commands for deployment and inspection.
What it assumes
Assumes Docker Engine, virtual machines, SSH access, and a Swarm-ready Compose file; explains manager and worker roles.
What you can do after
Operate/configure a named stack with Docker stack commands and redeploy changed services from its Compose file.
How it connects
Connects Docker Swarm stacks to Docker Compose, services, tasks, manager nodes, worker nodes, and Kubernetes namespaces.

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.