-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I have recently encountered a problem when building images using Docker BuildKit. When using --output=type=oci,dest=test-image.tar, the exporter creates images which I could not import on any Docker version available to me.
Here is a minimal reproducible example:
Dockerfile:
FROM alpine:3.18.3
RUN echo "This is a successful test" > /something.txt
CMD cat /something.txtCreate a buildx builder like so:
docker buildx create --use --bootstrap --name=regression --driver-opt=image=moby/buildkit:v0.12.1-rootless
Build and attempt to load the image:
docker buildx build --no-cache --provenance=false --tag=local-regression:latest --platform=linux/amd64 --pull --output=type=oci,dest=local-regression.tar .
docker image load -i local-regression.tar
Expected outcome:
The image gets loaded and is visible under docker images.
Actual outcome:
> docker image load -i local-regression.tar
open /var/lib/docker/tmp/docker-import-3510229865/blobs/json: no such file or directory
Tested building on:
- Docker Desktop version 4.22.0 (117440) under Windows 11 Pro, x64
- Docker Community version 24.0.2 (build cb74dfc) under Debian GNU/Linux 12 (Bookworm), x64
Tested image loading on:
- Docker Desktop version 4.22.0 (117440) under Windows 11 Pro, x64
- Docker Community version 24.0.2 (build cb74dfc) under Debian GNU/Linux 12 (Bookworm), x64
- Docker Community version 24.0.5 (build ced0996) under Debian GNU/Linux 11 (Bullseye), x64
- Docker Community version 24.0.5 (build ced0996) under Ubuntu GNU/Linux 22.04.2 LTS (Jammy), ARM64
Affected versions tested:
moby/buildkit:v0.12.1-rootlessmoby/buildkit:v0.12.0-rootless
Working versions tested:
moby/buildkit:v0.11.6-rootless
Workaround:
When creating a builder, explicitly pin the moby/buildkit image tag to version 0.11.6 or earlier, rootless variants included., for example:
> docker buildx create --use --bootstrap --name=regression --driver-opt=image=moby/buildkit:v0.11.6-rootless
... lots of output ...
> docker buildx build --no-cache --provenance=false --tag=local-regression:latest --platform=linux/amd64 --pull --output=type=oci,dest=local-regression.tar .
... lots of output ...
> docker image load -i
... lots of output ...
Loaded image ID: sha256:<some-sha>
> docker tag <the-above-sha> local-regression:latest
> docker run --rm local-regression:latest
This is a successful test