mirror of https://github.com/docker/docs.git
vendor: github.com/moby/buildkit 7cd12732690e
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
parent
799a04f05b
commit
ad4baa77de
|
@ -453,7 +453,7 @@ The exec form is parsed as a JSON array, which means that
|
|||
you must use double-quotes (") around words, not single-quotes (').
|
||||
|
||||
```dockerfile
|
||||
ENTRYPOINT ["/bin/bash", "-c", "echo", "hello"]
|
||||
ENTRYPOINT ["/bin/bash", "-c", "echo hello"]
|
||||
```
|
||||
|
||||
The exec form is best used to specify an `ENTRYPOINT` instruction, combined
|
||||
|
@ -564,8 +564,10 @@ The image can be any valid image.
|
|||
`FROM` instruction. Each `FROM` instruction clears any state created by previous
|
||||
instructions.
|
||||
- Optionally a name can be given to a new build stage by adding `AS name` to the
|
||||
`FROM` instruction. The name can be used in subsequent `FROM` and
|
||||
`COPY --from=<name>` instructions to refer to the image built in this stage.
|
||||
`FROM` instruction. The name can be used in subsequent `FROM <name>`,
|
||||
[`COPY --from=<name>`](#copy---from),
|
||||
and [`RUN --mount=type=bind,from=<name>`](#run---mounttypebind) instructions
|
||||
to refer to the image built in this stage.
|
||||
- The `tag` or `digest` values are optional. If you omit either of them, the
|
||||
builder assumes a `latest` tag by default. The builder returns an error if it
|
||||
can't find the `tag` value.
|
||||
|
@ -786,7 +788,7 @@ with support for passphrases.
|
|||
| `uid` | User ID for socket. Default `0`. |
|
||||
| `gid` | Group ID for socket. Default `0`. |
|
||||
|
||||
#### Example: access to Gitlab
|
||||
#### Example: access to GitLab
|
||||
|
||||
```dockerfile
|
||||
# syntax=docker/dockerfile:1
|
||||
|
@ -1361,6 +1363,7 @@ COPY [OPTIONS] ["<src>", ... "<dest>"]
|
|||
|
||||
The available `[OPTIONS]` are:
|
||||
|
||||
- [`--from`](#copy---from)
|
||||
- [`--chown`](#copy---chown---chmod)
|
||||
- [`--chmod`](#copy---chown---chmod)
|
||||
- [`--link`](#copy---link)
|
||||
|
@ -1426,10 +1429,10 @@ attempted to be used instead.
|
|||
|
||||
`COPY` obeys the following rules:
|
||||
|
||||
- The `<src>` path must be inside the build context;
|
||||
you can't use `COPY ../something /something`, because the builder can only
|
||||
access files from the context, and `../something` specifies a parent file or
|
||||
directory of the build context root.
|
||||
- The `<src>` path is resolved relative to the build context.
|
||||
If you specify a relative path leading outside of the build context, such as
|
||||
`COPY ../something /something`, parent directory paths are stripped out automatically.
|
||||
The effective source path in this example becomes `COPY something /something`
|
||||
|
||||
- If `<src>` is a directory, the entire contents of the directory are copied,
|
||||
including filesystem metadata.
|
||||
|
@ -1462,6 +1465,42 @@ attempted to be used instead.
|
|||
> guide – Leverage build cache](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache)
|
||||
> for more information.
|
||||
|
||||
### COPY --from
|
||||
|
||||
By default, the `COPY` instruction copies files from the build context. The
|
||||
`COPY --from` flag lets you copy files from an image, a build stage,
|
||||
or a named context instead.
|
||||
|
||||
```dockerfile
|
||||
COPY [--from=<image|stage|context>] <src> ... <dest>
|
||||
```
|
||||
|
||||
To copy from a build stage in a
|
||||
[multi-stage build](https://docs.docker.com/build/building/multi-stage/),
|
||||
specify the name of the stage you want to copy from. You specify stage names
|
||||
using the `AS` keyword with the `FROM` instruction.
|
||||
|
||||
```dockerfile
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM alpine AS build
|
||||
COPY . .
|
||||
RUN apk add clang
|
||||
RUN clang -o /hello hello.c
|
||||
|
||||
FROM scratch
|
||||
COPY --from=build /hello /
|
||||
```
|
||||
|
||||
You can also copy files directly from other images. The following example
|
||||
copies an `nginx.conf` file from the official Nginx image.
|
||||
|
||||
```dockerfile
|
||||
COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
|
||||
```
|
||||
|
||||
The source path of `COPY --from` is always resolved from filesystem root of the
|
||||
image or stage that you specify.
|
||||
|
||||
### COPY --chown --chmod
|
||||
|
||||
> **Note**
|
||||
|
@ -2098,14 +2137,6 @@ flag.
|
|||
> learn about secure ways to use secrets when building images.
|
||||
{ .warning }
|
||||
|
||||
|
||||
If you specify a build argument that wasn't defined in the Dockerfile,
|
||||
the build outputs a warning.
|
||||
|
||||
```console
|
||||
[Warning] One or more build-args [foo] were not consumed.
|
||||
```
|
||||
|
||||
A Dockerfile may include one or more `ARG` instructions. For example,
|
||||
the following is a valid Dockerfile:
|
||||
|
||||
|
@ -2449,15 +2480,11 @@ ONBUILD ADD . /app/src
|
|||
ONBUILD RUN /usr/local/bin/python-build --dir /app/src
|
||||
```
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> Chaining `ONBUILD` instructions using `ONBUILD ONBUILD` isn't allowed.
|
||||
{ .warning }
|
||||
### ONBUILD limitations
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The `ONBUILD` instruction may not trigger `FROM` or `MAINTAINER` instructions.
|
||||
{ .warning }
|
||||
- Chaining `ONBUILD` instructions using `ONBUILD ONBUILD` isn't allowed.
|
||||
- The `ONBUILD` instruction may not trigger `FROM` or `MAINTAINER` instructions.
|
||||
- `ONBUILD COPY --from` is [not supported](https://github.com/moby/buildkit/issues/816).
|
||||
|
||||
## STOPSIGNAL
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# github.com/moby/moby v26.0.0+incompatible
|
||||
# github.com/moby/buildkit v0.13.1
|
||||
# github.com/docker/buildx v0.13.1
|
||||
# github.com/moby/buildkit v0.13.0-rc3.0.20240402103816-7cd12732690e
|
||||
# github.com/docker/buildx v0.0.0-00010101000000-000000000000
|
||||
# github.com/docker/cli v26.0.0+incompatible
|
||||
# github.com/docker/compose/v2 v2.26.1
|
||||
# github.com/docker/compose/v2 v2.0.0-00010101000000-000000000000
|
||||
|
|
6
go.mod
6
go.mod
|
@ -7,8 +7,8 @@ toolchain go1.21.1
|
|||
require (
|
||||
github.com/docker/buildx v0.13.1 // indirect
|
||||
github.com/docker/cli v26.0.0+incompatible // indirect
|
||||
github.com/docker/compose/v2 v2.26.1 // indirect
|
||||
github.com/moby/buildkit v0.13.0 // indirect
|
||||
github.com/docker/compose/v2 v2.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/moby/buildkit v0.13.1 // indirect
|
||||
github.com/moby/moby v26.0.0+incompatible // indirect
|
||||
)
|
||||
|
||||
|
@ -16,6 +16,6 @@ replace (
|
|||
github.com/docker/buildx => github.com/docker/buildx v0.13.1
|
||||
github.com/docker/cli => github.com/docker/cli v26.0.0+incompatible
|
||||
github.com/docker/compose/v2 => github.com/docker/compose/v2 v2.26.1
|
||||
github.com/moby/buildkit => github.com/moby/buildkit v0.13.0-rc3.0.20240308080452-a38011b9f57d
|
||||
github.com/moby/buildkit => github.com/moby/buildkit v0.13.0-rc3.0.20240402103816-7cd12732690e
|
||||
github.com/moby/moby => github.com/moby/moby v26.0.0+incompatible
|
||||
)
|
||||
|
|
3
go.sum
3
go.sum
|
@ -220,6 +220,8 @@ github.com/moby/buildkit v0.13.0-rc3.0.20240307092343-22d4212fed7e h1:lEQehVlOgE
|
|||
github.com/moby/buildkit v0.13.0-rc3.0.20240307092343-22d4212fed7e/go.mod h1:P5zIr3pyh1VQoK751o5JFtogepVcLi9+77PTfmvJwls=
|
||||
github.com/moby/buildkit v0.13.0-rc3.0.20240308080452-a38011b9f57d h1:q8sI5enL3NBniNUIeVyrbUj6WCSc0gg+tAQgX1m6oTM=
|
||||
github.com/moby/buildkit v0.13.0-rc3.0.20240308080452-a38011b9f57d/go.mod h1:P5zIr3pyh1VQoK751o5JFtogepVcLi9+77PTfmvJwls=
|
||||
github.com/moby/buildkit v0.13.0-rc3.0.20240402103816-7cd12732690e h1:+hA09x+9xK3KoXtxNFHiJxBbJrpVr/7UR221F2+pG9w=
|
||||
github.com/moby/buildkit v0.13.0-rc3.0.20240402103816-7cd12732690e/go.mod h1:ij4XbVmcwOPQdTJQeO6341hqzvlw10kkuSsT36suSrk=
|
||||
github.com/moby/buildkit v0.13.0 h1:reVR1Y+rbNIUQ9jf0Q1YZVH5a/nhOixZsl+HJ9qQEGI=
|
||||
github.com/moby/buildkit v0.13.0/go.mod h1:aNmNQKLBFYAOFuzQjR3VA27/FijlvtBD1pjNwTSN37k=
|
||||
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
|
||||
|
@ -252,6 +254,7 @@ github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVn
|
|||
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
|
||||
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
|
||||
github.com/opencontainers/image-spec v1.1.0-rc6 h1:XDqvyKsJEbRtATzkgItUqBA7QHk58yxX1Ov9HERHNqU=
|
||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
|
Loading…
Reference in New Issue