Docker StacksΒΆ
Docker Stack sits at a higher level than Docker containers and helps to manage the orchestration of multiple containers across several machines. Docker Stack is run across a Docker Swarm.
Docker Stack can be seen as the Docker Swarm version of Docker Compose.
For example, in Docker Stack, we also have compose-like files that essentially do a very similar thing: build Docker services from images.
Putting everything together that we've learned, here is a file called stack.yml
defining a Docker stack:
version: '3.3'
services:
router:
image: traefik:v2.2
deploy:
placement:
constraints:
- node.role == manager
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- maestro-production
networks:
maestro-production:
external: true
We can now deploy this stack using the command:
The--with-registry-auth
flag allows the stack to download images from private DockerHub repositories, assuming your docker login
credentials entered have access to it.
Here is an example diagram that explains how everything we've learned in Docker comes together: