-
Notifications
You must be signed in to change notification settings - Fork 451
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
--load doesn't always export the Docker image #593
Comments
Need reproduction steps. |
Hi @tonistiigi, I've created a repo which reproduces the problem: https://github.com/benhjames/buildx-bug You can see the issue in action here: https://github.com/benhjames/buildx-bug/runs/2328156905 All you need to do is run the workflow to observe the bug. At the end of the "Build image" stage, you can see that it runs "importing to docker" and reports this as done. However, when subsequently running |
Turns out that the runner was running out of disk space, see docker/build-push-action#321 for details. If it would be possible to make |
I ran into the same issue. It seems like a bug if the build command exits 0 while the load fails. |
Looks like an upstream issue: moby/moby#34416. cc @thaJeztah. |
2017 :-0 At this point, is it possible for buildx to do the right thing (maybe verify somehow) independently, since it seems correct from the buildx side to exit non zero if |
This seems reasonable for me. |
Just left a comment on that issue, but that behaviour is expected, as the endpoint only returns the status code based on the initial request received; the actual success/fail must be determined based on the progress response. |
I expect a user friendly CLI to behave safely by default:
The @moby issue implies that only the HTTP status code is 200, but the actual JSON payload returned in response contains the keys |
Figured it out: set -e
docker buildx build ... --output="type=docker,push=false,name=$REPOSITORY:$TAG,dest=/tmp/img.tar" .
docker load --input /tmp/img.tar
rm -f /tmp/img.tar |
Note that if you output to tar it will not be loaded and this is expected behaviour, see docker/build-push-action#413 ("multiple exporters are not supported"). If you want your image both loaded in docker and exported, you have to (I know this is an unrelated issue, just leaving a note here in case people land here that are trying to do the above) |
That’s why my code block contains But as said, my code is a workaround, not a fix. A fix means that if the user specified “I want to load this image” and the action failed to load this image, the action should fail with an informative error message. And this is also not an upstream error. As said in moby/moby#34416 (comment), once a header has been sent, it cannot be changed. Buildx therefore needs to read and interpret the JSON payload instead of going by the HTTP status alone here: That streaming endpoint responds (eventually) with a JSON payload that has a success or error message. Buildx should wait for the final response and succeed or fail accordingly:
|
So this is simple. The bug is here: buildx/vendor/github.com/docker/docker/client/image_load.go Lines 21 to 24 in ac85f59
buildx treats that endpoint as a normal one, not a streaming one. What it needs to do here is looping over all responses and bailing once it receives an error, even when that one comes with HTTP 200. |
This issue is more comprehensively described in the below linked issue, but since it appears to be an issue in buildx itself, I've opened an issue here to track. Hope that's ok!
Original ref: docker/build-push-action#321
The gist of it is that building an image with buildx doesn't always export the image to Docker:
Running
docker image ls
immediately after this does not list the exported image, despite the build step apparently succeeding:I've only managed to reproduce this on 1 out of 3 different images (as described in original issue) which is pretty weird. The only real difference between them is their size: the failing one is much bigger than the other two.
Let me know if you need any more info! 🙂
The text was updated successfully, but these errors were encountered: