Skip to content

Commit

Permalink
compose V2 G.A
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Sep 7, 2021
1 parent 1211358 commit 24a624c
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 250 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Expand Up @@ -22,7 +22,7 @@ exclude: ["_samples", "_scripts", "404.html", "datacenter", "ee", "index.html",
# You can't have - characters in these for non-YAML reasons
latest_engine_api_version: "1.41"
docker_ce_version: "20.10"
compose_version: "1.29.2"
compose_version: "2.0.0"
compose_file_v3: "3.9"
compose_file_v2: "2.4"
machine_version: "0.16.0"
Expand Down
2 changes: 1 addition & 1 deletion _data/toc.yaml
Expand Up @@ -1314,7 +1314,7 @@ manuals:
- path: /compose/cli-command/
title: Overview
- path: /compose/cli-command-compatibility/
title: Compose v2 compatibility
title: Compatibility
- path: /compose/install/
title: Install Compose
- path: /compose/gettingstarted/
Expand Down
3 changes: 0 additions & 3 deletions _includes/content/compose-extfields-sub.md
Expand Up @@ -9,7 +9,6 @@ your Compose file and their name start with the `x-` character sequence.
> of service, volume, network, config and secret definitions.
```yaml
version: "{{ site.compose_file_v3 }}"
x-custom:
items:
- a
Expand All @@ -35,7 +34,6 @@ logging:
You may write your Compose file as follows:

```yaml
version: "{{ site.compose_file_v3 }}"
x-logging:
&default-logging
options:
Expand All @@ -56,7 +54,6 @@ It is also possible to partially override values in extension fields using
the [YAML merge type](https://yaml.org/type/merge.html). For example:

```yaml
version: "{{ site.compose_file_v3 }}"
x-volumes:
&default-volume
driver: foobar-storage
Expand Down
56 changes: 4 additions & 52 deletions compose/cli-command.md
@@ -1,23 +1,14 @@
---
description: Compose V2 RC1 in the Docker CLI
keywords: compose, V2, release candidate RC 1
title: Compose V2 release candidate
description: Compose V2
keywords: compose, V2
title: Compose V2
---

## 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 available as a release candidate with the Docker Desktop 3.6 release.
>
> 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 running `docker compose`, instead of `docker-compose`.
>
> As Docker Compose V2 is a release candidate, we recommend that you extensively test before using it in production environments.
{: .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](#installing-compose-v2) for detailed instructions how to enable the drop-in replacement.

We will gradually turn this option on automatically for Docker Desktop users, so that users can seamlessly move to Docker Compose V2 without the need to upgrade any of their scripts. If you run into any problems with Compose V2, you can easily switch back to Compose v1 by either by making changes in Docker Desktop **Experimental** Settings, or by running the command `docker-compose disable-v2`.
We turn this option on automatically for Docker Desktop users, so that users can seamlessly move to Docker Compose V2 without the need to upgrade any of their scripts. If you run into any problems with Compose V2, you can easily switch back to Compose v1 by either by making changes in Docker Desktop Settings, or by running the command `docker-compose disable-v2`.

Your feedback is important to us. Let us know your feedback on the new 'compose' command by creating an issue in the [Compose](https://github.com/docker/compose/issues){:target="_blank" rel="noopener" class="_"} GitHub repository.
{: .important}
Expand All @@ -31,42 +22,3 @@ While docker-compose is still supported and maintained, Compose V2 implementatio
Additionally, Compose V2 also supports [Apple silicon](../desktop/mac/apple-silicon.md).

For more information about the flags that are supported in the new compose command, see the [docker-compose compatibility list](cli-command-compatibility.md).

## Installing Compose V2

This section contains instructions on how to install Compose V2.

### Install on Mac and Windows

**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 the Compose V2 separately.

**Docker Desktop for Mac and for Windows version 3.4.0** and above also includes `docker-compose` drop-in replacement, allowing users to choose to use Compose V2 when using the `docker-compose` command.

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:

- [Install Docker Desktop on Mac](../desktop/mac/install.md)
- [Install Docker Desktop on Windows](../desktop/windows/install.md)

To disable Docker Compose V2 using Docker Desktop:

1. From the Docker menu, click **Preferences** (**Settings** on Windows) > **Experimental features**.
2. Clear the **Use Docker Compose V2** check box.

To disable Docker Compose V2 using the CLI, run:

```console
$ docker-compose disable-v2
```

### Install on Linux

You can install Compose V2 by downloading the adequate binary for your system
from the [project release page](https://github.com/docker/compose/releases){:target="_blank" rel="noopener" class="_"} and copying it into `$HOME/.docker/cli-plugins` as `docker-compose`.

```console
$ mkdir -p ~/.docker/cli-plugins/
$ curl -SL https://github.com/docker/compose/releases/download/v2.0.0-rc.3/docker-compose-linux-amd64 -o ~/.docker/cli-plugins/docker-compose
$ chmod +x ~/.docker/cli-plugins/docker-compose
```
29 changes: 12 additions & 17 deletions compose/environment-variables.md
Expand Up @@ -48,19 +48,18 @@ $ cat .env
TAG=v1.5

$ cat docker-compose.yml
version: '3'
services:
web:
image: "webapp:${TAG}"
```

When you run `docker-compose up`, the `web` service defined above uses the
When you run `docker compose up`, the `web` service defined above uses the
image `webapp:v1.5`. You can verify this with the
[config command](reference/config.md), which prints your resolved application
config to the terminal:

```console
$ docker-compose config
$ docker compose config

version: '3'
services:
Expand All @@ -75,7 +74,7 @@ uses that instead:

```console
$ export TAG=v2.0
$ docker-compose config
$ docker compose config

version: '3'
services:
Expand All @@ -92,7 +91,7 @@ appropriately, for example, `.env.ci`, `.env.dev`, `.env.prod`. Passing the file
done using the `--env-file` option:

```console
$ docker-compose --env-file ./config/.env.dev up
$ docker compose --env-file ./config/.env.dev up
```

This file path is relative to the current working directory where the Docker Compose
Expand All @@ -107,7 +106,6 @@ TAG=v1.6


$ cat docker-compose.yml
version: '3'
services:
web:
image: "webapp:${TAG}"
Expand All @@ -116,8 +114,7 @@ services:
The `.env` file is loaded by default:

```console
$ docker-compose config
version: '3'
$ docker compose config
services:
web:
image: 'webapp:v1.5'
Expand All @@ -126,8 +123,7 @@ services:
Passing the `--env-file ` argument overrides the default file path:

```console
$ docker-compose --env-file ./config/.env.dev config
version: '3'
$ docker compose --env-file ./config/.env.dev config
services:
web:
image: 'webapp:v1.6'
Expand All @@ -136,7 +132,7 @@ services:
When an invalid file path is being passed as `--env-file` argument, Compose returns an error:

```console
$ docker-compose --env-file ./doesnotexist/.env.dev config
$ docker compose --env-file ./doesnotexist/.env.dev config
ERROR: Couldn't find env file: /home/user/./doesnotexist/.env.dev
```

Expand Down Expand Up @@ -184,19 +180,19 @@ web:
- web-variables.env
```

## Set environment variables with 'docker-compose run'
## Set environment variables with 'docker compose run'

Similar to `docker run -e`, you can set environment variables on a one-off
container with `docker-compose run -e`:
container with `docker compose run -e`:

```console
$ docker-compose run -e DEBUG=1 web python console.py
$ docker compose run -e DEBUG=1 web python console.py
```

You can also pass a variable from the shell by not giving it a value:

```console
$ docker-compose run -e DEBUG web python console.py
$ docker compose run -e DEBUG web python console.py
```

The value of the `DEBUG` variable in the container is taken from the value for
Expand All @@ -219,7 +215,6 @@ $ cat ./Docker/api/api.env
NODE_ENV=test

$ cat docker-compose.yml
version: '3'
services:
api:
image: 'node:6-alpine'
Expand All @@ -233,7 +228,7 @@ When you run the container, the environment variable defined in the Compose
file takes precedence.

```console
$ docker-compose exec api node
$ docker compose exec api node

> process.env.NODE_ENV
'production'
Expand Down
10 changes: 5 additions & 5 deletions compose/extends.md
Expand Up @@ -31,7 +31,7 @@ the rules described in
To use multiple override files, or an override file with a different name, you
can use the `-f` option to specify the list of files. Compose merges files in
the order they're specified on the command line. See the
[`docker-compose` command reference](reference/index.md) for more information
[`docker compose` command reference](reference/index.md) for more information
about using `-f`.

When you use multiple configuration files, you must make sure all paths in the
Expand Down Expand Up @@ -99,7 +99,7 @@ cache:
- 6379:6379
```

When you run `docker-compose up` it reads the overrides automatically.
When you run `docker compose up` it reads the overrides automatically.

Now, it would be nice to use this Compose app in a production environment. So,
create another override file (which might be stored in a different git
Expand All @@ -122,7 +122,7 @@ cache:
To deploy with this production Compose file you can run

```console
$ docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
$ docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```

This deploys all three services using the configuration in
Expand Down Expand Up @@ -161,11 +161,11 @@ export or backup.
- db
```

To start a normal environment run `docker-compose up -d`. To run a database
To start a normal environment run `docker compose up -d`. To run a database
backup, include the `docker-compose.admin.yml` as well.

```console
$ docker-compose -f docker-compose.yml -f docker-compose.admin.yml \
$ docker compose -f docker-compose.yml -f docker-compose.admin.yml \
run dbadmin db-backup
```

Expand Down
8 changes: 4 additions & 4 deletions compose/faq.md
Expand Up @@ -63,21 +63,21 @@ or the [`COMPOSE_PROJECT_NAME` environment variable](reference/envvars.md#compos

## What's the difference between `up`, `run`, and `start`?

Typically, you want `docker-compose up`. Use `up` to start or restart all the
Typically, you want `docker compose up`. Use `up` to start or restart all the
services defined in a `docker-compose.yml`. In the default "attached"
mode, you see all the logs from all the containers. In "detached" mode (`-d`),
Compose exits after starting the containers, but the containers continue to run
in the background.

The `docker-compose run` command is for running "one-off" or "adhoc" tasks. It
The `docker compose run` command is for running "one-off" or "adhoc" tasks. It
requires the service name you want to run and only starts containers for services
that the running service depends on. Use `run` to run tests or perform
an administrative task such as removing or adding data to a data volume
container. The `run` command acts like `docker run -ti` in that it opens an
interactive terminal to the container and returns an exit status matching the
exit status of the process in the container.

The `docker-compose start` command is useful only to restart containers
The `docker compose start` command is useful only to restart containers
that were previously created, but were stopped. It never creates new
containers.

Expand All @@ -88,7 +88,7 @@ any JSON file should be valid Yaml. To use a JSON file with Compose,
specify the filename to use, for example:

```console
$ docker-compose -f docker-compose.json up
$ docker compose -f docker-compose.json up
```

## Should I include my code with `COPY`/`ADD` or a volume?
Expand Down

0 comments on commit 24a624c

Please sign in to comment.