From ba54a6519ec7fbd1812d127c0a8d6ec4a44ec316 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 6 Aug 2021 17:05:48 +0200 Subject: [PATCH] develop/develop-images: use "console" for shell examples This allows for easier copying of the commands, without selecting the prompt. Signed-off-by: Sebastiaan van Stijn --- develop/develop-images/baseimages.md | 10 +++--- develop/develop-images/build_enhancements.md | 4 +-- .../dockerfile_best-practices.md | 32 +++++++++---------- develop/develop-images/multistage-build.md | 4 +-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/develop/develop-images/baseimages.md b/develop/develop-images/baseimages.md index 8c60450b2d..b0f2e76703 100644 --- a/develop/develop-images/baseimages.md +++ b/develop/develop-images/baseimages.md @@ -73,8 +73,8 @@ Assuming you built the "hello" executable example by using the source code at and you compiled it with the `-static` flag, you can build this Docker image using this `docker build` command: -```bash -docker build --tag hello . +```console +$ docker build --tag hello . ``` Don't forget the `.` character at the end, which sets the build context to the @@ -84,7 +84,7 @@ current directory. > you need a Linux binary, rather than a Mac or Windows binary. > You can use a Docker container to build it: > -> ```bash +> ```console > $ docker run --rm -it -v $PWD:/build ubuntu:20.04 > > container# apt-get update && apt-get install build-essential @@ -94,8 +94,8 @@ current directory. To run your new image, use the `docker run` command: -```bash -docker run --rm hello +```console +$ docker run --rm hello ``` This example creates the hello-world image used in the tutorials. diff --git a/develop/develop-images/build_enhancements.md b/develop/develop-images/build_enhancements.md index 1393bb119b..00614c2de4 100644 --- a/develop/develop-images/build_enhancements.md +++ b/develop/develop-images/build_enhancements.md @@ -37,7 +37,7 @@ the [Dockerfile reference](/engine/reference/builder/) page. Easiest way from a fresh install of docker is to set the `DOCKER_BUILDKIT=1` environment variable when invoking the `docker build` command, such as: -```bash +```console $ DOCKER_BUILDKIT=1 docker build . ``` @@ -226,7 +226,7 @@ RUN --mount=type=ssh git clone git@github.com:myorg/myproject.git myproject Once the `Dockerfile` is created, use the `--ssh` option for connectivity with the SSH agent. -```bash +```console $ docker build --ssh default . ``` diff --git a/develop/develop-images/dockerfile_best-practices.md b/develop/develop-images/dockerfile_best-practices.md index 6fa2d2f8c8..7f7be9327c 100644 --- a/develop/develop-images/dockerfile_best-practices.md +++ b/develop/develop-images/dockerfile_best-practices.md @@ -73,21 +73,21 @@ context. > a text file named `hello` and create a Dockerfile that runs `cat` on it. Build > the image from within the build context (`.`): > -> ```shell -> mkdir myproject && cd myproject -> echo "hello" > hello -> echo -e "FROM busybox\nCOPY /hello /\nRUN cat /hello" > Dockerfile -> docker build -t helloapp:v1 . +> ```console +> $ mkdir myproject && cd myproject +> $ echo "hello" > hello +> $ echo -e "FROM busybox\nCOPY /hello /\nRUN cat /hello" > Dockerfile +> $ docker build -t helloapp:v1 . > ``` > > Move `Dockerfile` and `hello` into separate directories and build a second > version of the image (without relying on cache from the last build). Use `-f` > to point to the Dockerfile and specify the directory of the build context: > -> ```shell -> mkdir -p dockerfiles context -> mv Dockerfile dockerfiles && mv hello context -> docker build --no-cache -t helloapp:v2 -f dockerfiles/Dockerfile context +> ```console +> $ mkdir -p dockerfiles context +> $ mv Dockerfile dockerfiles && mv hello context +> $ docker build --no-cache -t helloapp:v2 -f dockerfiles/Dockerfile context > ``` Inadvertently including files that are not necessary for building an image @@ -664,7 +664,7 @@ RUN echo $ADMIN_USER > ./mark RUN unset ADMIN_USER ``` -```bash +```console $ docker run --rm test sh -c 'echo $ADMIN_USER' mark @@ -687,7 +687,7 @@ RUN export ADMIN_USER="mark" \ CMD sh ``` -```bash +```console $ docker run --rm test sh -c 'echo $ADMIN_USER' ``` @@ -762,13 +762,13 @@ CMD ["--help"] Now the image can be run like this to show the command's help: -```bash +```console $ docker run s3cmd ``` Or using the right parameters to execute a command: -```bash +```console $ docker run s3cmd ls s3://mybucket ``` @@ -819,19 +819,19 @@ This script allows the user to interact with Postgres in several ways. It can simply start Postgres: -```bash +```console $ docker run postgres ``` Or, it can be used to run Postgres and pass parameters to the server: -```bash +```console $ docker run postgres postgres --help ``` Lastly, it could also be used to start a totally different tool, such as Bash: -```bash +```console $ docker run --rm -it postgres bash ``` diff --git a/develop/develop-images/multistage-build.md b/develop/develop-images/multistage-build.md index 9831325814..611b6aea13 100644 --- a/develop/develop-images/multistage-build.md +++ b/develop/develop-images/multistage-build.md @@ -116,7 +116,7 @@ CMD ["./app"] You only need the single Dockerfile. You don't need a separate build script, either. Just run `docker build`. -```bash +```console $ docker build -t alexellis2/href-counter:latest . ``` @@ -160,7 +160,7 @@ Dockerfile including every stage. You can specify a target build stage. The following command assumes you are using the previous `Dockerfile` but stops at the stage named `builder`: -```bash +```console $ docker build --target builder -t alexellis2/href-counter:latest . ```