mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
Merge pull request #1000 from tonistiigi/docs-named-context
docs: make sure syntax with latest stable dockerfile image is defined
This commit is contained in:
commit
ca2718366e
@ -123,7 +123,8 @@ On Windows:
|
|||||||
Here is how to install and use Buildx inside a Dockerfile through the
|
Here is how to install and use Buildx inside a Dockerfile through the
|
||||||
[`docker/buildx-bin`](https://hub.docker.com/r/docker/buildx-bin) image:
|
[`docker/buildx-bin`](https://hub.docker.com/r/docker/buildx-bin) image:
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM docker
|
FROM docker
|
||||||
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
RUN docker buildx version
|
RUN docker buildx version
|
||||||
@ -298,6 +299,7 @@ inside your Dockerfile and can be leveraged by the processes running as part
|
|||||||
of your build.
|
of your build.
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
|
@ -128,7 +128,8 @@ $ docker buildx build --build-context project=path/to/project/source .
|
|||||||
# docker buildx build --build-context project=https://github.com/myuser/project.git .
|
# docker buildx build --build-context project=https://github.com/myuser/project.git .
|
||||||
```
|
```
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM alpine
|
FROM alpine
|
||||||
COPY --from=project myfile /
|
COPY --from=project myfile /
|
||||||
```
|
```
|
||||||
@ -141,10 +142,10 @@ Source an image from a local [OCI layout compliant directory](https://github.com
|
|||||||
$ docker buildx build --build-context foo=oci-layout:///path/to/local/layout@sha256:abcd12345 .
|
$ docker buildx build --build-context foo=oci-layout:///path/to/local/layout@sha256:abcd12345 .
|
||||||
```
|
```
|
||||||
|
|
||||||
```Dockerfile
|
```dockerfile
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM alpine
|
FROM alpine
|
||||||
RUN apk add git
|
RUN apk add git
|
||||||
|
|
||||||
COPY --from=foo myfile /
|
COPY --from=foo myfile /
|
||||||
|
|
||||||
FROM foo
|
FROM foo
|
||||||
@ -475,7 +476,7 @@ Attribute keys:
|
|||||||
- `src`, `source` - Secret filename. `id` used if unset.
|
- `src`, `source` - Secret filename. `id` used if unset.
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1
|
||||||
FROM python:3
|
FROM python:3
|
||||||
RUN pip install awscli
|
RUN pip install awscli
|
||||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
||||||
@ -494,7 +495,7 @@ Attribute keys:
|
|||||||
- `env` - Secret environment variable. `id` used if unset, otherwise will look for `src`, `source` if `id` unset.
|
- `env` - Secret environment variable. `id` used if unset, otherwise will look for `src`, `source` if `id` unset.
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1
|
||||||
FROM node:alpine
|
FROM node:alpine
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=type=secret,id=SECRET_TOKEN \
|
--mount=type=secret,id=SECRET_TOKEN \
|
||||||
@ -526,7 +527,7 @@ authentication (e.g., cloning a private repository).
|
|||||||
Example to access Gitlab using an SSH agent socket:
|
Example to access Gitlab using an SSH agent socket:
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1
|
||||||
FROM alpine
|
FROM alpine
|
||||||
RUN apk add --no-cache openssh-client
|
RUN apk add --no-cache openssh-client
|
||||||
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
|
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
|
||||||
|
Loading…
Reference in New Issue
Block a user