Dockerfile frontend experimental syntaxes
https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md
You can build images with BuildKit on Docker 18.06 or later. With BuildKit, RUN instructions in Dockerfile accept --mount option. It can be used as a volume for build-time. For example, RUN --mount=type=cache,target=/var/cache/apt apt-get install ... means “Mount /var/cache/apt as a cache directory while running the command”. The cache remains in Docker host machine until you remove it with docker builder prune. In other words, you can share cache files among two or more build without writing them in the images.
To use these experimental features today, you have to enable BuildKit and put a comment # syntax=docker/dockerfile:experimental in the first line of your Dockerfile. BuildKit can be enabled as follows:
- Docker 18.06 or later: put
"experimental": trueinto the/etc/docker/daemon.jsonand setexport DOCKER_BUILDKIT=1before build. - Docker 18.09 or later: put
"features": {"buildkit": true}into the/etc/docker/daemon.jsonor setexport DOCKER_BUILDKIT=1before build.