testcontainers / testcontainers/testcontainers-java
Make it possible to use build docker image using BuildKit
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ImageFromDockerfile build path and the Docker client ImageBuild request mentioned in the issue, then compare how Docker CLI enables BuildKit and passes version=2. Verify the Docker API behavior for that parameter. Done means the provided Dockerfile using RUN --mount builds successfully through GenericContainer without the Unknown flag error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- build-system, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100