What is a Docker Stack?
A Stack is the top-level unit of Docker Swarm deployment. It groups multiple services together and manages their shared networking and storage.
Our cluster will run a stack called jlar (or any name you choose) containing these services:
| Service | Image | Port | Replicas |
|---|---|---|---|
| wordpress | arm32v7/wordpress | 8000 → 80 | 4 |
| db (MariaDB) | jorgenlarsen/mariadb10.3:rpi | 3306 | 1 |
| phpmyadmin | arm32v7/phpmyadmin | 8080 → 80 | 4 |
| portainer | portainer/portainer-ce | 9000 | 1 |
| netdata | netdata/netdata | 19999 | 1 per node |
Key Concepts
Services
A service is the definition of how a container should run within Swarm — which image, how many replicas, which ports to expose, which network to join.
Tasks
Each replica of a service is called a task. Swarm scheduler places tasks across available nodes.
Stacks vs Compose
Both use docker-compose.yml files, but they work differently:
| docker-compose | docker stack deploy | |
|---|---|---|
| Target | Single host | Multi-node Swarm |
| Scaling | Manual | Automatic across nodes |
| Deploy key | Ignored | Honoured |
| Use case | Dev / local testing | Production cluster |
Step-by-Step with Portainer GUI
After deploying the stack you can explore all its components through Portainer's browser interface:
- Stacks — list and manage deployed stacks
- Services — scale replicas, view logs, update images
- Containers — inspect running container instances per node
- Networks — visualise overlay and bridge networks
- Volumes — manage persistent data
- Images — list locally cached images on each node
- Swarm — overview of all cluster nodes