You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature is only enabled if [BuildKit](#buildkit) backend is used.
266
+
267
+
Syntax directive defines the location of the Dockerfile builder that is used for
268
+
building the current Dockerfile. BuildKit backend allows to seamlessly use
269
+
external implementations of builders that are distributed as Docker images and
270
+
execute inside a container sandbox environment.
271
+
272
+
Using a custom Dockerfile implementation allows you to:
273
+
- Automatically get bugfixes without updating the daemon
274
+
- Make sure all users are using the same implementation to build your Dockerfile
275
+
- Use the latest features without updating the daemon
276
+
- Try out new experimental or third party features
277
+
278
+
### Official releases
279
+
280
+
Docker distributes official versions of the images that can be used for building
281
+
Dockerfiles under `docker/dockerfile` repository on Docker Hub. There are two
282
+
channels where new images are released: stable and experimental.
283
+
284
+
Stable channel follows semantic versioning. For example:
285
+
286
+
- docker/dockerfile:1.0.0 - only allow immutable version 1.0.0
287
+
- docker/dockerfile:1.0 - allow versions 1.0.*
288
+
- docker/dockerfile:1 - allow versions 1.*.*
289
+
- docker/dockerfile:latest - latest release on stable channel
290
+
291
+
The experimental channel uses incrementing versioning with the major and minor
292
+
component from the stable channel on the time of the release. For example:
293
+
294
+
- docker/dockerfile:1.0.1-experimental - only allow immutable version 1.0.1-experimental
295
+
- docker/dockerfile:1.0-experimental - latest experimental releases after 1.0
296
+
- docker/dockerfile:experimental - latest release on experimental channel
297
+
298
+
You should choose a channel that best fits your needs. If you only want
299
+
bugfixes, you should use `docker/dockerfile:1.0` while if you're going to use
300
+
experimental features, you should use the experimental channel. If you are using
301
+
the experimental channel, the new releases may not be backward compatible, so it
302
+
is recommended to use an immutable full version variant.
303
+
304
+
For master builds and nightly feature releases refer to the description in [the source repository](https://github.com/moby/buildkit/blob/master/README.md).
305
+
231
306
## escape
232
307
233
308
# escape=\ (backslash)
@@ -1623,6 +1698,31 @@ RUN echo "Hello World"
1623
1698
When building this Dockerfile, the `HTTP_PROXY` is preserved in the
1624
1699
`docker history`, and changing its value invalidates the build cache.
1625
1700
1701
+
### Automatic platform ARGs in the global scope
1702
+
1703
+
This feature is only available when using [BuildKit](#buildkit) backend.
1704
+
1705
+
Docker has a set of predefined `ARG` variables that are automatically defined with the information based on the current platform of the node performing the build and the platform of the build result specified with the `--platform` flag on `docker build`.
1706
+
1707
+
* TARGETPLATFORM - platform of the build result. Eg `linux/amd64`, `linux/arm/v7`, `windows/amd64`.
1708
+
* TARGETOS - OS component of TARGETPLATFORM
1709
+
* TARGETARCH - architecture component of TARGETPLATFORM
1710
+
* TARGETVARIANT - variant component of TARGETPLATFORM
1711
+
* BUILDPLATFORM - platform of the node performing the build.
1712
+
* BUILDOS - OS component of BUILDPLATFORM
1713
+
* BUILDARCH - OS component of BUILDPLATFORM
1714
+
* BUILDVARIANT - - OS component of BUILDPLATFORM
1715
+
1716
+
These arguments are defined in the global scope so are not automatically available inside build stages or for your `RUN` commands. To expose one of these arguments inside the build stage redefine it without value.
1717
+
1718
+
For example:
1719
+
1720
+
```
1721
+
FROM alpine
1722
+
ARG TARGETPLATFORM
1723
+
RUN echo "I'm building for $TARGETPLATFORM"
1724
+
```
1725
+
1626
1726
### Impact on build caching
1627
1727
1628
1728
`ARG` variables are not persisted into the built image as `ENV` variables are.
@@ -1931,6 +2031,14 @@ required such as `zsh`, `csh`, `tcsh` and others.
1931
2031
1932
2032
The `SHELL` feature was added in Docker 1.12.
1933
2033
2034
+
## Experimental features
2035
+
2036
+
This feature is only available when using [BuildKit](#buildkit) backend.
2037
+
2038
+
Docker build supports experimental features like cache mounts, build secrets and
2039
+
ssh forwarding that are enabled by using an external implementation of the
2040
+
builder with a syntax directive. To learn about these features, [refer to the docs in BuildKit repository](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md).
2041
+
1934
2042
## Dockerfile examples
1935
2043
1936
2044
Below you can see some examples of Dockerfile syntax. If you're interested in
0 commit comments