"Supporting" buildkit/buildx #573
Replies: 4 comments 2 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.
-
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