Docker Tip #23: Docker Compose vs Docker Stack

Docker Compose and Docker Stack can both be controlled by a docker-compose.yml file. Learn the differences between them.
Docker Compose is an official tool that helps you manage your Docker containers by letting you define everything through a docker-compose.yml
file.
docker stack
is a command that’s embedded into the Docker CLI. It lets you manage a cluster of Docker containers through Docker Swarm.
It just so happens both Docker Compose and the docker stack
command support the same docker-compose.yml
file with slightly different features.
In some cases, certain features that only work with docker stack
are ignored by Docker Compose, and likewise, unsupported features of Docker Compose are ignored by the docker stack
command.
For example, the deploy
property is ignored by Docker Compose and depends_on
is ignored by docker stack
. There are other differences too. You can find them out by checking out the official Compose file reference. It will call out Compose or Stack specific properties.
I really like what Docker did here. This allows you to define a single docker-compose.yml
that works for both Docker Compose and docker stack
which is a nice quality of life improvement if you happen to use Docker Compose in development and Docker Swarm in production.