description | keywords | title |
---|---|---|
Docker Compose |
compose, V2 |
Compose V2 |
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 test the Compose V2 by simply replacing the dash (-
) with a space, and by runningdocker compose
, instead ofdocker-compose
. {: .important}
Starting with Docker Desktop 3.4.0, you can run Compose V2 commands without modifying your invocations, by enabling the drop-in replacement of the previous docker-compose
with the new command. See the section Installing Compose V2 for detailed instructions how to enable the drop-in replacement.
Introduction of the Compose specification{:target="blank" rel="noopener" class=""} makes a clean distinction between the Compose YAML file model and the docker-compose
implementation. Making this change has enabled a number of enhancements, including adding the compose
command directly into the Docker CLI, being able to “up” a Compose application on cloud platforms by simply switching the Docker context, and launching of Amazon ECS and Microsoft ACI. As the Compose specification evolves, new features land faster in the Docker CLI.
While docker-compose
is still supported and maintained, Compose V2 implementation relies directly on the compose-go bindings which are maintained as part of the specification. This allows us to include community proposals, experimental implementations by the Docker CLI and/or Engine, and deliver features faster to users. Compose V2 also supports some of the newer additions to the Compose specification, such as profiles and GPU devices.
Additionally, Compose V2 also supports Apple silicon.
For more information about the flags that are supported in the new compose command, see the docker-compose compatibility list.
We are currently working towards providing a standard way to install Compose V2 on Linux. When this is available, Compose V2 will be marked as Generally Available (GA).
Compose V2 GA means:
- New features and bug fixes will only be considered in the Compose V2 code base.
- Docker Compose V2 will be the default setting in Docker Desktop for Mac and Windows. You can still opt out through the Docker Desktop UI and the CLI. This means, when you run
docker-compose
, you will actually be runningdocker compose
. - Compose V2 will be included with the latest version of the Docker CLI. You can use Compose Switch to redirect
docker-compose
todocker compose
. - Compose V2 branch will become the default branch.
- Docker Compose V1 will be maintained to address any security issues.
Important
We would like to make the Compose V2 transition to be as smooth as possible for all users. We currently don't have a concrete timeline to deprecate Compose V1. We will review the feedback from the community on the GA and the adoption on Linux, and come up with a plan to deprecate Compose V1. We are not planning to remove the aliasing of
docker-compose
todocker compose
. We would like to make it easier for users to switch to V2 without breaking any existing scripts. We will follow up with a blog post with more information on the exact timeline on V1 deprecation and the end of support policies for security issues.Your feedback is important to us. Reach out to us and let us know your feedback on our Public Roadmap{:target="blank" rel="noopener" class=""}. {: .important}
This section contains instructions on how to install Compose V2.
Docker Desktop for Mac and for Windows version 3.2.1 and above includes the new Compose command along with the Docker CLI. Therefore, Windows and Mac users do not need to install Compose V2 separately.
We will progressively turn Docker Compose V2 on automatically for Docker Desktop users, so that users can seamlessly move to Docker Compose V2 without the need to change any of their scripts. If you run into any problems with Compose V2, you can simply switch back to Compose v1, either in Docker Desktop, or in the CLI.
For Docker Desktop installation instructions, see:
To disable Docker Compose V2 using Docker Desktop:
- From the Docker menu, click Preferences (Settings on Windows) > General.
- Clear the Use Docker Compose V2 check box.
To disable Docker Compose V2 using the CLI, run:
$ docker-compose disable-v2
You can install Compose V2 by downloading the appropriate binary for your system
from the project release page{:target="blank" rel="noopener" class=""} and copying it into $HOME/.docker/cli-plugins
as docker-compose
.
-
Run the following command to download the current stable release of Docker Compose:
$ mkdir -p ~/.docker/cli-plugins/ $ curl -SL https://github.com/docker/compose/releases/download/v{{site.compose_v2_version}}/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
This command installs Compose V2 for the active user under
$HOME
directory. To install Docker Compose for all users on your system, replace~/.docker/cli-plugins
with/usr/local/lib/docker/cli-plugins
. -
Apply executable permissions to the binary:
$ chmod +x ~/.docker/cli-plugins/docker-compose
-
Test your installation
$ docker compose version Docker Compose version {{site.compose_v2_version}}
Compose Switch{:target="blank" rel="noopener" class=""} is a replacement to the Compose V1 docker-compose
(python) executable. Compose switch translates the command line into Compose V2 docker compose
and then runs the latter.
To install Compose Switch automatically, run:
$ curl -fL https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
To install Compose Switch manually:
-
Download the
compose-switch
binary for your architecture$ curl -fL https://github.com/docker/compose-switch/releases/download/v{{site.compose_switch_version}}/docker-compose-linux-amd64 -o /usr/local/bin/compose-switch
-
Run the following command to make it an executable:
$ chmod +x /usr/local/bin/compose-switch
-
Rename the
docker-compose
binary if you've already installed it as/usr/local/bin/docker-compose
$ mv /usr/local/bin/docker-compose /usr/local/bin/docker-compose-v1
-
Define an alternatives group for the
docker-compose
command:$ update-alternatives --install /usr/local/bin/docker-compose docker-compose <PATH_TO_DOCKER_COMPOSE_V1> 1 $ update-alternatives --install /usr/local/bin/docker-compose docker-compose /usr/local/bin/compose-switch 99
-
Verify your installation:
$ update-alternatives --display docker-compose docker-compose - auto mode link best version is /usr/local/bin/compose-switch link currently points to /usr/local/bin/compose-switch link docker-compose is /usr/local/bin/docker-compose /usr/bin/docker-compose - priority 1 /usr/local/bin/compose-switch - priority 99
If you installed Docker Compose using curl, run the following command to uninstall:
$ sudo rm ~/.docker/cli-plugins/docker-compose