I have been using docker-compose
, but noticed there is also a docker compose
(without the dash).
I have not been able to quickly determine the differences between the two forms by googling.
Anyone?
docker compose
's help:
docker-compose
's help:
In summary, Docker is the underlying technology used to create images and run them as containers, and Docker Compose is a tool that configures how Docker should run multiple containers to serve our application.
Docker Compose is used for configuring and starting multiple Docker containers on the same host–so you don't have to start each container separately. Docker swarm is a container orchestration tool that allows you to run and connect containers on multiple hosts.
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.
A Dockerfile is a text document that contains all the commands/Instruction a user could call on the command line to assemble an image. Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services.
It's a client application to the docker daemon server, kind of like the docker CLI client, but instead of typing the whole run commands every time, with docker-compose you can re-use the same YAML file over and over again, and deploy the same container with the same configuration as you did in the first time.
Using Compose is basically a three-step process: Define your app’s environment with a Dockerfile so it can be reproduced anywhere. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment. Run docker-compose up and Compose starts and runs your entire app.
It has to be the most recent one, which is 3 at the time of writing, while Docker Compose still can handle versions 2 and 3 without problems. Both docker-compose and the new docker stack commands can be used with docker-compose.yml files which are written according to the specification of version 3.
The docker compose
(with a space) is a newer project to migrate compose to Go with the rest of the docker project. This is the v2
branch of the docker/compose repo. It's been first introduced to Docker Desktop users, so docker users on Linux didn't see the command. In addition to migrating to Go, it uses the compose-spec, and part of the rewrite may result in behavior differences.
The original python project, called docker-compose
, aka v1 of docker/compose repo, has now been deprecated and development has moved over to v2. To install the v2 docker compose
as a CLI plugin on Linux, supported distribution can now install the docker-compose-plugin
package. E.g. on debian, I run apt-get install docker-compose-plugin
.
Brandon Mitchell from docker's Captain Program replied to the github issue I opened on this as follows:
The docker/compose-cli project is in an in-between state, where it's not available in upstream releases of the docker-cli Linux packages, but is being included in Docker Desktop. The documentation pages normally follow what's in the docker/cli, so having this released to Desktop early puts the documentation in a difficult position. I'm going to raise this issue with the Docker team to see how they'd like to handle it.
Update: from docker github issue:
gtardif commented 2 days ago
compose command reference doc is now live
new docker-compose command reference
Quote from https://docs.docker.com/compose/#compose-v2-and-the-new-docker-compose-command
Compose V2 and the new docker compose command
Important
The new Compose V2,
which supports the compose command as part of the Docker CLI, is now available.
Compose V2 integrates compose functions into the Docker platform,
continuing to support most of the previous docker-compose features and flags.
You can run Compose V2 by replacing the hyphen (-) with a space,
using docker compose, instead of docker-compose.
If it not yet included in the docker
installation, docker compose
can be installed on Linux as CLI plugin.
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
See https://docs.docker.com/compose/cli-command/#installing-compose-v2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With