mirror of https://github.com/docker/docs.git
compose: use "console" for shell examples
This allows for easier copying of the commands, without selecting the prompt. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ac1be36710
commit
ae3b5b66f9
|
@ -44,7 +44,7 @@ available.
|
||||||
|
|
||||||
3. Add the following to your `~/.bash_profile`:
|
3. Add the following to your `~/.bash_profile`:
|
||||||
|
|
||||||
```shell
|
```bash
|
||||||
if [ -f $(brew --prefix)/etc/bash_completion ]; then
|
if [ -f $(brew --prefix)/etc/bash_completion ]; then
|
||||||
. $(brew --prefix)/etc/bash_completion
|
. $(brew --prefix)/etc/bash_completion
|
||||||
fi
|
fi
|
||||||
|
@ -59,7 +59,7 @@ completion.
|
||||||
|
|
||||||
2. Add the following lines to `~/.bash_profile`:
|
2. Add the following lines to `~/.bash_profile`:
|
||||||
|
|
||||||
```shell
|
```bash
|
||||||
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
|
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
|
||||||
. /opt/local/etc/profile.d/bash_completion.sh
|
. /opt/local/etc/profile.d/bash_completion.sh
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -42,7 +42,7 @@ named `.env`. The `.env` file path is as follows:
|
||||||
in `+v1.28` by limiting the filepath to the project directory.
|
in `+v1.28` by limiting the filepath to the project directory.
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ cat .env
|
$ cat .env
|
||||||
TAG=v1.5
|
TAG=v1.5
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ image `webapp:v1.5`. You can verify this with the
|
||||||
[config command](reference/config.md), which prints your resolved application
|
[config command](reference/config.md), which prints your resolved application
|
||||||
config to the terminal:
|
config to the terminal:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ docker-compose config
|
$ docker-compose config
|
||||||
|
|
||||||
version: '3'
|
version: '3'
|
||||||
|
@ -72,7 +72,7 @@ Values in the shell take precedence over those specified in the `.env` file.
|
||||||
If you set `TAG` to a different value in your shell, the substitution in `image`
|
If you set `TAG` to a different value in your shell, the substitution in `image`
|
||||||
uses that instead:
|
uses that instead:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ export TAG=v2.0
|
$ export TAG=v2.0
|
||||||
$ docker-compose config
|
$ docker-compose config
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ By passing the file as an argument, you can store it anywhere and name it
|
||||||
appropriately, for example, `.env.ci`, `.env.dev`, `.env.prod`. Passing the file path is
|
appropriately, for example, `.env.ci`, `.env.dev`, `.env.prod`. Passing the file path is
|
||||||
done using the `--env-file` option:
|
done using the `--env-file` option:
|
||||||
|
|
||||||
```shell
|
```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
|
This file path is relative to the current working directory where the Docker Compose
|
||||||
command is executed.
|
command is executed.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ cat .env
|
$ cat .env
|
||||||
TAG=v1.5
|
TAG=v1.5
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ services:
|
||||||
|
|
||||||
The `.env` file is loaded by default:
|
The `.env` file is loaded by default:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ docker-compose config
|
$ docker-compose config
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
|
@ -122,7 +122,7 @@ services:
|
||||||
```
|
```
|
||||||
Passing the `--env-file ` argument overrides the default file path:
|
Passing the `--env-file ` argument overrides the default file path:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ docker-compose --env-file ./config/.env.dev config
|
$ docker-compose --env-file ./config/.env.dev config
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
|
@ -186,14 +186,14 @@ web:
|
||||||
Similar to `docker run -e`, you can set environment variables on a one-off
|
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`:
|
||||||
|
|
||||||
```shell
|
```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:
|
You can also pass a variable from the shell by not giving it a value:
|
||||||
|
|
||||||
```shell
|
```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
|
The value of the `DEBUG` variable in the container is taken from the value for
|
||||||
|
@ -211,7 +211,7 @@ priority used by Compose to choose which value to use:
|
||||||
In the example below, we set the same environment variable on an Environment
|
In the example below, we set the same environment variable on an Environment
|
||||||
file, and the Compose file:
|
file, and the Compose file:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ cat ./Docker/api/api.env
|
$ cat ./Docker/api/api.env
|
||||||
NODE_ENV=test
|
NODE_ENV=test
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ services:
|
||||||
When you run the container, the environment variable defined in the Compose
|
When you run the container, the environment variable defined in the Compose
|
||||||
file takes precedence.
|
file takes precedence.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ docker-compose exec api node
|
$ docker-compose exec api node
|
||||||
|
|
||||||
> process.env.NODE_ENV
|
> process.env.NODE_ENV
|
||||||
|
|
|
@ -158,7 +158,7 @@ is the automated test suite. Automated end-to-end testing requires an
|
||||||
environment in which to run tests. Compose provides a convenient way to create
|
environment in which to run tests. Compose provides a convenient way to create
|
||||||
and destroy isolated testing environments for your test suite. By defining the full environment in a [Compose file](compose-file/index.md), you can create and destroy these environments in just a few commands:
|
and destroy isolated testing environments for your test suite. By defining the full environment in a [Compose file](compose-file/index.md), you can create and destroy these environments in just a few commands:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
$ ./run_tests
|
$ ./run_tests
|
||||||
$ docker-compose down
|
$ docker-compose down
|
||||||
|
|
|
@ -125,8 +125,8 @@ also included below.
|
||||||
|
|
||||||
1. Run this command to download the current stable release of Docker Compose:
|
1. Run this command to download the current stable release of Docker Compose:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
sudo curl -L "https://github.com/docker/compose/releases/download/{{site.compose_version}}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
$ sudo curl -L "https://github.com/docker/compose/releases/download/{{site.compose_version}}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
> To install a different version of Compose, substitute `{{site.compose_version}}`
|
> To install a different version of Compose, substitute `{{site.compose_version}}`
|
||||||
|
@ -137,8 +137,8 @@ also included below.
|
||||||
|
|
||||||
2. Apply executable permissions to the binary:
|
2. Apply executable permissions to the binary:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
sudo chmod +x /usr/local/bin/docker-compose
|
$ sudo chmod +x /usr/local/bin/docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**: If the command `docker-compose` fails after installation, check your path.
|
> **Note**: If the command `docker-compose` fails after installation, check your path.
|
||||||
|
@ -146,8 +146,8 @@ also included below.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Optionally, install [command completion](completion.md) for the
|
3. Optionally, install [command completion](completion.md) for the
|
||||||
|
@ -155,7 +155,7 @@ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
||||||
|
|
||||||
4. Test the installation.
|
4. Test the installation.
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
$ docker-compose --version
|
$ docker-compose --version
|
||||||
docker-compose version {{site.compose_version}}, build 1110ad01
|
docker-compose version {{site.compose_version}}, build 1110ad01
|
||||||
```
|
```
|
||||||
|
@ -182,13 +182,13 @@ dependencies. See the [virtualenv
|
||||||
tutorial](https://docs.python-guide.org/dev/virtualenvs/) to get
|
tutorial](https://docs.python-guide.org/dev/virtualenvs/) to get
|
||||||
started.
|
started.
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
pip install docker-compose
|
$ pip install docker-compose
|
||||||
```
|
```
|
||||||
If you are not using virtualenv,
|
If you are not using virtualenv,
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
sudo pip install docker-compose
|
$ sudo pip install docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
> pip version 6.0 or greater is required.
|
> pip version 6.0 or greater is required.
|
||||||
|
@ -198,9 +198,9 @@ sudo pip install docker-compose
|
||||||
Compose can also be run inside a container, from a small bash script wrapper. To
|
Compose can also be run inside a container, from a small bash script wrapper. To
|
||||||
install compose as a container run this command:
|
install compose as a container run this command:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
sudo curl -L --fail https://github.com/docker/compose/releases/download/{{site.compose_version}}/run.sh -o /usr/local/bin/docker-compose
|
$ sudo curl -L --fail https://github.com/docker/compose/releases/download/{{site.compose_version}}/run.sh -o /usr/local/bin/docker-compose
|
||||||
sudo chmod +x /usr/local/bin/docker-compose
|
$ sudo chmod +x /usr/local/bin/docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -239,29 +239,29 @@ your existing containers (for example, because they have data volumes you want
|
||||||
to preserve), you can use Compose 1.5.x to migrate them with the following
|
to preserve), you can use Compose 1.5.x to migrate them with the following
|
||||||
command:
|
command:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
docker-compose migrate-to-labels
|
$ docker-compose migrate-to-labels
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, if you're not worried about keeping them, you can remove them.
|
Alternatively, if you're not worried about keeping them, you can remove them.
|
||||||
Compose just creates new ones.
|
Compose just creates new ones.
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
docker container rm -f -v myapp_web_1 myapp_db_1 ...
|
$ docker container rm -f -v myapp_web_1 myapp_db_1 ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Uninstallation
|
## Uninstallation
|
||||||
|
|
||||||
To uninstall Docker Compose if you installed using `curl`:
|
To uninstall Docker Compose if you installed using `curl`:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
sudo rm /usr/local/bin/docker-compose
|
$ sudo rm /usr/local/bin/docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
To uninstall Docker Compose if you installed using `pip`:
|
To uninstall Docker Compose if you installed using `pip`:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
pip uninstall docker-compose
|
$ pip uninstall docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
> Got a "Permission denied" error?
|
> Got a "Permission denied" error?
|
||||||
|
|
Loading…
Reference in New Issue