When to use Docker-Compose and when to use Docker-Swarm

More or less.

There is a Compose file format (3.0+) which is used to create docker stacks that consist of docker services with just the (Go-based) Docker engine. The motivation for using the same file format is that it is easier to pick up for users already familiar with it.

Now, a bit confusingly, there is a (separate) Python program called docker-compose which does orchestration too. This is the “Compose” you’re likely familiar with. It accepts files in the same format and in the latest versions makes similar API requests as just (Go-based) docker binary. Think about the new stuff as mostly rolling into the Docker Engine, things which were only in Compose before. “Stacks” and “services” are slightly newer terminology, but the end goal is largely the same: container orchestration.

One Compose file (usually) => One docker stack.

If you don’t need --link, you can simply create a docker network and drop containers (part of a service) on it. They can then reach each other with a built-in DNS entry based on service name (e.g., if the service you want to reach is called db, db should resolve to the service’s “virtual IP” within the container.

1 Like