From ae3b5b66f937c0699aa27dfe260fcabc8fbe1b78 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 6 Aug 2021 17:15:27 +0200 Subject: [PATCH] compose: use "console" for shell examples This allows for easier copying of the commands, without selecting the prompt. Signed-off-by: Sebastiaan van Stijn --- compose/completion.md | 4 +-- compose/environment-variables.md | 28 ++++++++++---------- compose/index.md | 2 +- compose/install.md | 44 ++++++++++++++++---------------- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/compose/completion.md b/compose/completion.md index 447ecba761..f87867f013 100644 --- a/compose/completion.md +++ b/compose/completion.md @@ -44,7 +44,7 @@ available. 3. Add the following to your `~/.bash_profile`: - ```shell + ```bash if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi @@ -59,7 +59,7 @@ completion. 2. Add the following lines to `~/.bash_profile`: - ```shell + ```bash if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then . /opt/local/etc/profile.d/bash_completion.sh fi diff --git a/compose/environment-variables.md b/compose/environment-variables.md index c1f1ff475c..4879c3a666 100644 --- a/compose/environment-variables.md +++ b/compose/environment-variables.md @@ -42,7 +42,7 @@ named `.env`. The `.env` file path is as follows: in `+v1.28` by limiting the filepath to the project directory. -```shell +```console $ cat .env 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 to the terminal: -```shell +```console $ docker-compose config 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` uses that instead: -```shell +```console $ export TAG=v2.0 $ 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 done using the `--env-file` option: -```shell -docker-compose --env-file ./config/.env.dev up +```console +$ docker-compose --env-file ./config/.env.dev up ``` This file path is relative to the current working directory where the Docker Compose command is executed. -```shell +```console $ cat .env TAG=v1.5 @@ -113,7 +113,7 @@ services: The `.env` file is loaded by default: -```shell +```console $ docker-compose config version: '3' services: @@ -122,7 +122,7 @@ services: ``` Passing the `--env-file ` argument overrides the default file path: -```shell +```console $ docker-compose --env-file ./config/.env.dev config version: '3' services: @@ -186,14 +186,14 @@ web: Similar to `docker run -e`, you can set environment variables on a one-off container with `docker-compose run -e`: -```shell -docker-compose run -e DEBUG=1 web python console.py +```console +$ 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: -```shell -docker-compose run -e DEBUG web python console.py +```console +$ docker-compose run -e DEBUG web python console.py ``` 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 file, and the Compose file: -```shell +```console $ cat ./Docker/api/api.env NODE_ENV=test @@ -229,7 +229,7 @@ services: When you run the container, the environment variable defined in the Compose file takes precedence. -```shell +```console $ docker-compose exec api node > process.env.NODE_ENV diff --git a/compose/index.md b/compose/index.md index d23aa98bc2..638ce84ff7 100644 --- a/compose/index.md +++ b/compose/index.md @@ -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 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 $ ./run_tests $ docker-compose down diff --git a/compose/install.md b/compose/install.md index 654d64114b..7e4df68924 100644 --- a/compose/install.md +++ b/compose/install.md @@ -125,8 +125,8 @@ also included below. 1. Run this command to download the current stable release of Docker Compose: - ```bash - 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 + ```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 ``` > 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: - ```bash - sudo chmod +x /usr/local/bin/docker-compose + ```console + $ sudo chmod +x /usr/local/bin/docker-compose ``` > **Note**: If the command `docker-compose` fails after installation, check your path. @@ -146,8 +146,8 @@ also included below. For example: -```bash -sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose +```console +$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose ``` 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. - ```bash + ```console $ docker-compose --version 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 started. -```bash -pip install docker-compose +```console +$ pip install docker-compose ``` If you are not using virtualenv, -```bash -sudo pip install docker-compose +```console +$ sudo pip install docker-compose ``` > 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 install compose as a container run this command: -```bash -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 +```console +$ 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 ``` @@ -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 command: -```bash -docker-compose migrate-to-labels +```console +$ docker-compose migrate-to-labels ``` Alternatively, if you're not worried about keeping them, you can remove them. Compose just creates new ones. -```bash -docker container rm -f -v myapp_web_1 myapp_db_1 ... +```console +$ docker container rm -f -v myapp_web_1 myapp_db_1 ... ``` ## Uninstallation To uninstall Docker Compose if you installed using `curl`: -```bash -sudo rm /usr/local/bin/docker-compose +```console +$ sudo rm /usr/local/bin/docker-compose ``` To uninstall Docker Compose if you installed using `pip`: -```bash -pip uninstall docker-compose +```console +$ pip uninstall docker-compose ``` > Got a "Permission denied" error?