testcontainers / testcontainers/testcontainers-java

Make it possible to use build docker image using BuildKit

Open
#2,857 14 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

resolution/acknowledged resolution/somedaymaybe
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

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.