"Supporting" buildkit/buildx #573
Replies: 5 comments 4 replies
-
Also, if anyone sees a need for things such as Buildah, Buildpacks, img, Kaniko, etc then the interface could be abstracted to something like type ContainerBuilder interface {
CreateContainer(context.Context, ContainerRequest) (Container, error)
} Instead. |
Beta Was this translation helpful? Give feedback.
-
Also: good news, it looks like Docker Desktop might respond to a client instance after all. I was able to create a container and run it with -v |
Beta Was this translation helpful? Give feedback.
-
For some reason, I've not seen this discussion before. Sorry. I'll go deep into it next week to understand it better. |
Beta Was this translation helpful? Give feedback.
-
Any updates on this work? |
Beta Was this translation helpful? Give feedback.
-
Ok, so I am one of the folks who is touching on this unlucky use case. I have a requirement to be able to cross-compile testcontainers targeting As of today -- the way you're led to implement this by the docker docs etc is by using buildkit-only syntax. I know there are ways to do this on pre-buildkit, but how things are in 2025 ends up making this issue more puzzling than it really is. May I suggest a short-term change to the docs around Subsequently, a bunch of the newer syntactical API surface of Docker around cross-compilation, multiplatform images and multi stage builds is not available by default. E.g.,by default using I don't think this is really said anywhere in a prominent way (probably because it ultimately is just surfacing some deeper programmatic docker API -- 🎉 Yes you can already use buildkit with go-testcontainers and fix these issues today! 🎉:
Now I can do everything I need, and the change to I also think this is a big enough deal that perhaps there should be a first-class Many have also just made it the default (e.g goreleaser's docker capabilities), and perhaps that's the ultimate fix and the most appropriate one given buildkit maturity. Albeit, one that probably needs a major version bump to put in place. Sorry for the annoying ping, but I'm going to tag mdelapenya for thoughts on above suggestions as its potentially high-impact low-hanging-fruit judging by upvotes across this thread/comments, and I was minutes away from giving up as well before discovering it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
As buildkit features like parallel builds, secrets and cache mounts become more popular, container testing frameworks like testcontainers-go should work to support them. This is something that is gaining traction for the original implementation, but has not come to pass yet.
There was an [issue](for this) with testcontainers-go once upon a time, but it evolved into the regular docker API build implementation and the original idea was dropped. This discussion seeks to resume that effort, since it would be pretty great for testcontainers-go to support buildkit, no matter how provisional, and I believe it could conceivably be staged to increase support over time.
The problems facing implementation are that buildkit does not have an HTTP api that I'm aware of. It's all over a GRPC communication with the daemon over unix socket. Compounding this, as far as I've been able to determine, Docker Desktop has their own closed GRPC API separate from the original implementation. Poking at the client on my macbooks has revealed it talking to
/Users/<me>/.docker/run/docker-cli-api.sock
, but it will not answer the standard moby tools likebuildctl
.This doesn't have to be the end of the world, though, as most, if not all, features can be hooked via interaction with the CLI, and this should be more than enough for the initial option to simply build and tag images with buildkit instead of plain Docker, falling back to the API for the rest of the container lifecycle. Obviously, more advanced features would be better, but I think this can be done iteratively.
Phase 1
Implement an initial (and optional)
BuildkitProvider
type as an interfaceAnd provide only one, implementation:
This can remain opaque until such time as more options are needed and researched (such as those provided by
buildx
), so long as they are germane to testcontainers usage.CLIBuildkitProvider
could then be attached similarly to other options:If set in
DockerProviderOptions
, theBuildkitProvider
would be delegated to to build the image. In the case of the initialCLIBuildkitProvider
, this would involve callingos.Exec
to rundocker build
withDOCKER_BUILDKIT=1
set in the environment. The CLI will also be used to label the image so that it can be claimed by the reaper.Phase 2
Later work could include providing both
as well as
Taking advantage of the moby/buildkit client library to interface with the daemon over GRPC
Phase 3
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions