Skip to content

Commit dc6ec35

Browse files
committed
docs: restructure examples for context
Signed-off-by: ArthurFlag <[email protected]>
1 parent 57a1c97 commit dc6ec35

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

docs/reference/buildx_build.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,15 @@ Learn more about the built-in build arguments in the [Dockerfile reference docs]
240240
Define additional build context with specified contents. In Dockerfile the context can be accessed when `FROM name` or `--from=name` is used.
241241
When Dockerfile defines a stage with the same name it is overwritten.
242242

243-
The value can be a local source directory, [local OCI layout compliant directory](https://github.com/opencontainers/image-spec/blob/main/image-layout.md), container image (with docker-image:// prefix), Git or HTTP URL.
243+
The value can be a:
244244

245-
Replace `alpine:latest` with a pinned one:
245+
- local source directory
246+
- [local OCI layout compliant directory](https://github.com/opencontainers/image-spec/blob/main/image-layout.md)
247+
- container image
248+
- Git URL
249+
- HTTP URL
246250

247-
```console
248-
$ docker buildx build --build-context alpine=docker-image://alpine@sha256:0123456789 .
249-
```
251+
#### <a name="local-path"></a> Use a local path
250252

251253
Expose a secondary local source directory:
252254

@@ -255,6 +257,16 @@ $ docker buildx build --build-context project=path/to/project/source .
255257
# docker buildx build --build-context project=https://github.com/myuser/project.git .
256258
```
257259

260+
#### <a name="docker-image"></a> Use a container image
261+
262+
Use the `docker-image://` scheme.
263+
264+
Replace `alpine:latest` with a pinned one:
265+
266+
```console
267+
$ docker buildx build --build-context alpine=docker-image://alpine@sha256:0123456789 .
268+
```
269+
258270
```dockerfile
259271
# syntax=docker/dockerfile:1
260272
FROM alpine
@@ -263,7 +275,10 @@ COPY --from=project myfile /
263275

264276
#### <a name="source-oci-layout"></a> Use an OCI layout directory as build context
265277

266-
Source an image from a local [OCI layout compliant directory](https://github.com/opencontainers/image-spec/blob/main/image-layout.md),
278+
Use the `oci-layout:///` scheme.
279+
280+
Source an image from a local
281+
[OCI layout compliant directory](https://github.com/opencontainers/image-spec/blob/main/image-layout.md),
267282
either by tag, or by digest:
268283

269284
```console
@@ -281,7 +296,6 @@ FROM foo
281296
```
282297

283298
The OCI layout directory must be compliant with the [OCI layout specification](https://github.com/opencontainers/image-spec/blob/main/image-layout.md).
284-
You can reference an image in the layout using either tags, or the exact digest.
285299

286300
### <a name="builder"></a> Override the configured builder instance (--builder)
287301

0 commit comments

Comments
 (0)