Skip to main content

Dockerfile

# syntax = docker/dockerfile:1
# syntax = docker/dockerfile:experimental

内置变量

FROM alpine
ARG TARGETPLATFORM
envfor
TARGETPLATFORM构建结果的平台
TARGETOSOS of TARGETPLATFORM
TARGETARCHarch of TARGETPLATFORM
TARGETVARIANTvariant of TARGETPLATFORM
BUILDPLATFORM执行构建的节点的平台
BUILDOSOS of BUILDPLATFORM
BUILDARCHarch of BUILDPLATFORM
BUILDVARIANTvariant of BUILDPLATFORM
  • platform
    • linux/amd64, linux/arm/v7, windows/amd64

BuildKit 内置

ArgTypeDescription
BUILDKIT_CACHE_MOUNT_NSStringSet optional cache ID namespace.
BUILDKIT_CONTEXT_KEEP_GIT_DIRBoolTrigger git context to keep the .git directory.
BUILDKIT_INLINE_CACHE2BoolInline cache metadata to image config or not.
BUILDKIT_MULTI_PLATFORMBoolOpt into determnistic output regardless of multi-platform output or not.
BUILDKIT_SANDBOX_HOSTNAMEStringSet the hostname (default buildkitsandbox)
BUILDKIT_SYNTAXStringSet frontend image
SOURCE_DATE_EPOCHIntSet the UNIX timestamp for created image and layers. More info from reproducible builds. Supported since Dockerfile 1.5, BuildKit 0.11

ssh clone

FROM alpine
RUN --mount=type=ssh \
apk add git openssh-client \
&& install -m 0700 -d ~/.ssh \
&& ssh-keyscan github.com >> ~/.ssh/known_hosts \
&& git clone [email protected]:wener/wode.git