-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
As per Docker release 18.09 it is possible to mount cache (using BuildKit) explained
Example dockerfile
# syntax = docker/dockerfile:1.0-experimental
#RUN --mount=type=cache,target=/home/gradle/.gradle gradle build
However when build such image, it is gives an error
Dockerfile parse error line 12: Unknown flag: mount
Code to build:
new GenericContainer<>(
new ImageFromDockerfile()
.withDockerfile(Path.of("Dockerfile").toAbsolutePath())
)I order to build such docker image from CLI, you need to set DOCKER_BUILDKIT=1 in order to use buildkit.
While analyzing docker cli source code it seems like it is appending such query parameter to REST API call version=2
- Prepare build parameters
https://github.com/docker/cli/blob/master/cli/command/image/build_buildkit.go#L207 - sending request via client
https://github.com/docker/cli/blob/b350e14b1f83e1870a234ff2c554450707218204/vendor/github.com/docker/docker/client/image_build.go#L136
Unfortunately, I do not see any documented version parameters in the official API documentation.
https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild
trajano, gerrnot, herbatnik, kper and k-wojcik