-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
support building docker images using BuildKit #571
Comments
Hi @helmlover, see the parent issue: docker/for-linux#1136. BuildKit does not yet seem supported over the Docker HTTP API, as such is only currently available via the CLI. |
Hi, |
+1, we need support for this....curious if there a workaround available to achieve the RUN cache like functionality without buildkit features? |
It looks like what's necessary is a support for creating a session and running it in dockerode. Go implementation for that in terraform was added here - https://github.com/kreuzwerker/terraform-provider-docker/pull/387/files#diff-4596d40531ae2e21f6074d104e6dc7317537946b56d95df847c9209dfbe30fceR329 The session run code is here |
Note that the API does support using BuildKit with the The linked upstream issue (docker/for-linux#1136) is on a deprecated/seemingly abandoned repo. |
The main problem is with setting up a websocket connect for the session which is required for version 2. IIRC, |
I'm not sure about that, or the requirements for this module (as I'm just bubbling up the finding as I saw others waiting on an issue on an abandoned repo), but I am able to use |
I don't think that's right. Passing I quickly looked into it at some point and my impression was that is really not straight forward using build version 2 on the docker api. I am not sure about any of this but my impression was: You to have to implement a gRPC server on your side, then hijack the http connection to start a session which allow the docker daemon to make calls on your end!? It's baffling api design if you ask me 😁 |
@schummar I guess my verification was that prior to adding
which referenced a and after adding it, I was able to build the image successfully 🤷 I can close my DefinitelyTyped PR if adding it doesn't support all BuildKit features |
@mikeseese that's still a valid option and should be added there. It exists in docker's API description - https://docs.docker.com/engine/api/v1.45/#tag/Image/operation/ImageBuild |
Oh, I think you are right! When I was experimenting some weeks back I could not get this to work. But now I have tried it again and it seems it does work! Maybe something a new docker version quietly improved? Or I have just been doing it wrong all that time 🤣 |
Phew! I just finished creating a quick reproduction repo for quick testing; I was about to test |
Thank you @mikeseese for sharing the findings here! I don't know if I would've ever found that upstream issue 😄 |
I was testing it locally as a test from my PR to support in testcontainers-go was passing for me too with current docker. However, when I was switching to the older docker it was failing. I enabled debug to understand why the problem happens, which lead me to this logs:
This happens when the base image is not present locally before the build, buildx will try to download it, but won't have auth data - it'll check it even for dockerhub - and in order to get that auth data it will try to find a session (somewhere inside github.com/containerd/containerd/remotes/docker/resolver.go retryRequest -> util/resolver/authorizer.go (dockerAuthorizer.AddResponses) -> sessionauth.GetTokenAuthority -> sessionManager.Any (should return any session). After that I returned to the new docker version, wiped all local images and got the same error as with the old version. Then I've decided to check the repo with an example provided by @mikeseese (https://github.com/mikeseese/dockerode-buildkit) and it the example there is a code to download a base image before building. When I commented out the pull code, deleted the pulled image and tried to run it I got the same
|
Ya it seems like the Long story short, I think it's safe to say that moby/the docker engine has support for this issue (for some minimum version of Docker), but each client will need to implement the BuildKit client/server to fully realize support, making this issue not blocked by an upstream issue. |
Yeah, that's what I also found in #761. And that's also what stopped all my past experiments, because due to a bug (#771) |
Made some progress: apocas/dockerode#766 |
i get the no active sessions problem when using version 2. Is there any way to solve? I'm anxious to complete my task. thx |
The claim "Docker [...] Works out of the box." is no longer true.
That is because docker now uses BuildKit per default, while the BuildKit Dockerfile syntax is not supported when building docker images with testcontainers-node (e.g. with
GenericContainer.fromDockerfile(buildContext).build()
)When building a Dockerfile containing BuildKit-features e.g.
through testcontains-node (with
export 'DEBUG=testcontainers*'
), the output currently looks like:Exporting
export DOCKER_BUILDKIT=1
does not change the problem/output.PS: Sibling issue in testcontainers-java: testcontainers/testcontainers-java#2857
The text was updated successfully, but these errors were encountered: