4

According to the August 2017 article the core functionalities of docker-compose were integrated into the new docker stack command. At the end of the article, the author also assumes docker-compose will soon to be deprecated. The docker stack deploy documentation is currently pretty sparse.

The article is six months old now. So, is docker stack the way to go, or is there still some advantage in using docker-compose today? Especially, I will soon introduce Docker to students. Is it worth spending time studying with them details of docker-compose or should I just jump to docker stack?

6

There are a few features of docker-compose that are not implemented in docker stack deploy and vice versa.

With docker-compose, you can run privileged containers and change capabilities which is not supported with swarm services yet. You can also run a container that is designed to exit, e.g. a batch job, more intuitively in docker-compose than in swarm mode. If your containers are designed for sysadmin tasks, this may make more sense.

With docker stack deploy, you get access to secrets and configs, along with replication settings, configuration of rolling updates, ingress networking with the routing mesh, and various other swarm mode features. If your containers are designed for highly available microservices, this makes more sense.

Both of these use the same docker-compose.yml definition file (with version 3 required for swarm mode). That makes moving between the two fairly easy. There are also projects like compose-on-kubernetes and kompose that make the transition to kubernetes with the same stack definitions easy.

  • 1
    Thanks, @BMitch. Since I asked my question, I experimented a little bit more with docker stack. It is very seducing, but it requires some understanding of the basic swarm concepts and has a more complicated setup (esp. since it doesn't build image and needs images to be stored in a repository). Given my actual requirements are to provide a gentle introduction to Docker, I will certainly stick with docker-compose with my students. Especially since I didn't find any source corroborating a potential deprecation of that tool in short- to mid-term. – Sylvain Leroux Feb 1 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.