-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to use build docker image using BuildKit #2857
Comments
AFAIK Given that even Docker's official Python library (that is used in Docker Compose) have decided that it is easier to delegate it to an external binary, I am not sure there is much we can do here, unless we do the same (call /cc @rnorth |
@bsideup thanks for super fast reply... so given that it seems like not so easy to implement, do you have any workaround to recommend? My first idea is to get a dockerfile as string, do something like |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this. |
This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case. |
I'm interested in this, @pawelebe did you find a workaround? |
Let's reopen - we shouldn't have let this get stale, so I apologise. I think that buildkit is something we'll have to keep in mind, particularly if we want Testcontainers to retain the ability to build Dockerfiles while more and more buildkit features become relied upon. That said, I can't see any immediate way to do it without the For now as a workaround I'd suggest executing |
It's a bit janky but I used the workaround specified by @morth https://github.com/trajano/spring-cloud-demo/blob/78ad12e7db4198fbedd94d2b2a4e87f5ae5ff187/gateway/src/test/java/net/trajano/swarm/gateway/ContainerTests.java#L55-L61 perhaps people can use it as an example. UPDATE: corrected the line number as @sharongur pointed out The lines were supposed to show how I started a |
is there any update regarding this issue? i've upgraded my projects dockerfiles to use buildkit buildx and now all my testcontainer arent working anymore... i didnt quite understand how the demo you linked is of any help @trajano, would you mind elaborating ? |
@trajano so you are using the local machines docker-compose to build the image instead of the testcontainers dockerfile infrastructure and then just use the created image with testcontainers? |
That's correct, that way you take advantage of everything buildx has to offer including cache mounts and secrets. |
With testcontainers facing:
while using ImageFromDockerfile. NOTE: BuildKit is default since Docker 23. |
There's now a documented |
@qerub It still requires a significant client-side implementation though. |
I bumped into this as well today. However, in my specific case I was able to set up a workaround using gradle:
tasks.register("buildDockerImage", type = Exec::class) {
// Point this to your build directory
workingDir(project.rootDir.resolve(".."))
commandLine("docker", "build", "-t", "dansdata/database:test", ".")
}
tasks.named("test").get().dependsOn(tasks.named("buildDockerImage"))
class DansdataDbContainer private constructor() :
JdbcDatabaseContainer<DansdataDbContainer>(DockerImageName.parse("dansdata/database:test")) { |
As per Docker release
18.09
it is possible to mount cache (using BuildKit) explainedExample dockerfile
However when build such image, it is gives an error
Code to build:
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
https://github.com/docker/cli/blob/master/cli/command/image/build_buildkit.go#L207
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
The text was updated successfully, but these errors were encountered: