Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Docker Tip #23: Docker Compose vs Docker Stack

docker-tips-and-tricks.jpg

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.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.



Comments