What DEPLOY Does
Unlike docker-compose up (which runs on a single node), docker stack deploy:
- Distributes container replicas across all Swarm worker nodes
- Creates the overlay network so containers on different nodes can communicate
- Respects the
deploy:section of your compose file (replicas, placement constraints, update policies) - Enables built-in load balancing via the Swarm ingress router
Deploy the Stack
Run this command on the MASTER node from the directory containing your docker-compose.yml:
Run on MASTER
$ docker stack deploy --compose-file docker-compose.yml jlar
Creating network jlar_overlay
Creating service jlar_db
Creating service jlar_wordpress
Creating service jlar_phpmyadmin
jlar is the stack name — you can use anything. All service and network names will be prefixed with it.
Check Service Status
List all services in the stack
$ docker service ls
ID NAME MODE REPLICAS IMAGE
abc123def456 jlar_db replicated 1/1 jorgenlarsen/mariadb10.3:rpi
ghi789jkl012 jlar_wordpress replicated 4/4 arm32v7/wordpress:latest
mno345pqr678 jlar_phpmyadmin replicated 4/4 arm32v7/phpmyadmin:latest
Wait until all services show X/X (desired/running) replicas. Image pulls on slow SD card connections can take a few minutes.
Access Your Services
| Service | URL | Notes |
|---|---|---|
| WordPress | http://<MASTER-IP>:8000 | Any node IP works — Swarm ingress routes the request |
| phpMyAdmin | http://<MASTER-IP>:8080 | Database GUI |
| Portainer | http://<MASTER-IP>:9000 | Docker management GUI |
Update the Stack
Edit your docker-compose.yml and redeploy — Docker Swarm will perform a rolling update:
Redeploy after changes
$ docker stack deploy --compose-file docker-compose.yml jlar
Remove the Stack
Tear down all services
$ docker stack rm jlar
Official reference: docs.docker.com — docker stack deploy