docs/reference/builder: update example output, and some rephrasing

- update some examples to show the BuildKit output
- remove some wording about "images" being used for the build cache
- add a link to the `--cache-from` section
- added a link to "scanning your image with `docker scan`"
- updated link to "push your image"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-04-21 11:47:31 +02:00
parent 22b14dac8e
commit 17a9eb60e3
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 32 additions and 30 deletions

View File

@ -91,8 +91,13 @@ a preliminary validation of the `Dockerfile` and returns an error if the syntax
```console ```console
$ docker build -t test/myapp . $ docker build -t test/myapp .
Sending build context to Docker daemon 2.048 kB [+] Building 0.3s (2/2) FINISHED
Error response from daemon: Unknown instruction: RUNCMD => [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 60B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
error: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition:
dockerfile parse error line 2: unknown instruction: RUNCMD
``` ```
The Docker daemon runs the instructions in the `Dockerfile` one-by-one, The Docker daemon runs the instructions in the `Dockerfile` one-by-one,
@ -105,38 +110,35 @@ Note that each instruction is run independently, and causes a new image
to be created - so `RUN cd /tmp` will not have any effect on the next to be created - so `RUN cd /tmp` will not have any effect on the next
instructions. instructions.
Whenever possible, Docker will re-use the intermediate images (cache), Whenever possible, Docker uses a build-cache to accelerate the `docker build`
to accelerate the `docker build` process significantly. This is indicated by process significantly. This is indicated by the `CACHED` message in the console
the `Using cache` message in the console output. output. (For more information, see the [`Dockerfile` best practices guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/):
(For more information, see the [`Dockerfile` best practices guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/):
```console ```console
$ docker build -t svendowideit/ambassador . $ docker build -t svendowideit/ambassador .
Sending build context to Docker daemon 15.36 kB [+] Building 0.7s (6/6) FINISHED
Step 1/4 : FROM alpine:3.2 => [internal] load build definition from Dockerfile 0.1s
---> 31f630c65071 => => transferring dockerfile: 286B 0.0s
Step 2/4 : MAINTAINER SvenDowideit@home.org.au => [internal] load .dockerignore 0.1s
---> Using cache => => transferring context: 2B 0.0s
---> 2a1c91448f5f => [internal] load metadata for docker.io/library/alpine:3.2 0.4s
Step 3/4 : RUN apk update && apk add socat && rm -r /var/cache/ => CACHED [1/2] FROM docker.io/library/alpine:3.2@sha256:e9a2035f9d0d7ce 0.0s
---> Using cache => CACHED [2/2] RUN apk add --no-cache socat 0.0s
---> 21ed6e7fbb73 => exporting to image 0.0s
Step 4/4 : CMD env | grep _TCP= | (sed 's/.*_PORT_\([0-9]*\)_TCP=tcp:\/\/\(.*\):\(.*\)/socat -t 100000000 TCP4-LISTEN:\1,fork,reuseaddr TCP4:\2:\3 \&/' && echo wait) | sh => => exporting layers 0.0s
---> Using cache => => writing image sha256:1affb80ca37018ac12067fa2af38cc5bcc2a8f09963de 0.0s
---> 7ea8aef582cc => => naming to docker.io/library/mysocatimage 0.0s
Successfully built 7ea8aef582cc
``` ```
Build cache is only used from images that have a local parent chain. This means By default, the build cache is based results from previous builds on the machine
that these images were created by previous builds or the whole chain of images on which you are building. The `--cache-from` option also allows you to use a
was loaded with `docker load`. If you wish to use build cache of a specific build-cache that's distributed through an image registry refer to the
image you can specify it with `--cache-from` option. Images specified with [specifying external cache sources](commandline/build.md#specifying-external-cache-sources)
`--cache-from` do not need to have a parent chain and may be pulled from other section in the `docker build` command reference.
registries.
When you're done with your build, you're ready to look into [*Pushing a When you're done with your build, you're ready to look into [scanning your image with `docker scan`](https://docs.docker.com/engine/scan/),
repository to its registry*](https://docs.docker.com/engine/tutorials/dockerrepos/#/contributing-to-docker-hub). and [pushing your image to Docker Hub](https://docs.docker.com/docker-hub/repos/).
## BuildKit ## BuildKit
@ -2319,9 +2321,9 @@ Step 3/5 : RUN New-Item -ItemType Directory C:\Example
Directory: C:\ Directory: C:\
Mode LastWriteTime Length Name Mode LastWriteTime Length Name
---- ------------- ------ ---- ---- ------------- ------ ----
d----- 10/28/2016 11:26 AM Example d----- 10/28/2016 11:26 AM Example
---> 3f2fbf1395d9 ---> 3f2fbf1395d9