From what I read it seems that Docker-Compose is a tool to create multiple containers on a single host while Docker Swarm is a tool that can do the exact same thing but with more control and on multiple hosts with the help of Docker Stack. I went through the tutorial and also came across this thread:
docker-compose.yml vs docker-stack.yml what difference?
And I'm coming to the conclusion that there's no reason to ever use Docker-Compose when you can use Docker Swarm with Docker Stack. They can even use the same docker-compose.yml.
It seems that Docker-compose came before the swarm and stack and maybe the new solution of swarm + stack makes compose obsolete, but it still remains for legacy reasons. Is this thinking correct? If not, what benefits does Docker-Compose have over Docker Swarm and Docker Stack in terms of making a development or production environment?
It seems that Docker-compose came before the swarm and stack and maybe the new solution of swarm + stack makes compose obsolete, but it still remains for legacy reasons. Is this thinking correct?
In short, yes. Compose came before all the Swarm stuff (it originated as a 3rd party utility called fig
). To make matters worse, there are even two different Swarms, old Swarm (the one that was a separate tool) and Swarm Mode (which is built into the docker
binary these days).
It seems to be evolving into services and deployment concepts that get built into Docker. But I would guess Docker Compose and the Swarm Mode deployment stuff will live side by side for a while.
It is also beneficial to know that Docker Compose underpinnings live as a library called libcompose
(https://github.com/docker/libcompose) which other 3rd party utilities make use of to support the docker-compose.yml
file format for deploying (see Rancher and rancher-compose
as an example). I would imagine they would make an effort to continue support for libcompose
.
I am unclear if the Docker Swarm deployment stuff actually uses libcompose
. In my cursory searches, it would appear that Swarm Mode does not implement libcompose
and does its own thing. I am not sure how this relates to the future of Docker Compose and libcompose
. Interpret as you see fit...