Docker buildx (BuildKit) ignores docker images loaded into the local registry

Viewed 22

Does anybody know a way to use an image loaded into the local registry as a base image in a Dockerfile with BuildKit?

E.g. I have the following image loaded locally by:

$ docker buildx build --platform linux/amd64 -t gstreamer-amd64:1.20.3-1 --load .

After running this command I have the image:

$ docker images
REPOSITORY                           TAG              IMAGE ID       CREATED         SIZE
gstreamer-amd64                      1.20.3-1         9e5300b37ac4   22 hours ago    1.27GB

Then I have the following Dockerfile:

FROM gstreamer-amd64:1.20.3-1 AS base_image

If I try to build it with the following command everything goes well:

$ docker build .
# builds fine

But if I try to build it with buildx it fails:

$ docker buildx build .
 => ERROR [internal] load metadata for docker.io/library/gstreamer-amd64:1.20.3-1      1.0s
------
 > [internal] load metadata for docker.io/library/gstreamer-amd64:1.20.3-1:
------
Dockerfile:12
--------------------
  10 |     ARG NVMM2GL_PACK_NAME=nvmm2gl-$NVMM2GL_VER-$REVISION-$ARCH
  11 |     
  12 | >>> FROM gstreamer-amd64:1.20.3-1 AS base_image
  13 |     
  14 |     RUN echo "Hello world" && exit 1
--------------------
ERROR: failed to solve: gstreamer-amd64:1.20.3-1: pull access denied, repository does
not exist or may require authorization: server message: insufficient_scope: authorization failed

So with BuildKit it completely ignores the local images.

As a workaround I run a local registry server:

$ docker run -d -p 5000:5000 --restart=always --name local-registry registry:2

Push my images there and use them in the Dockerfile:

FROM localhost:5000/gstreamer-amd64:1.20.3-1 AS base_image

This way it works, but I think it is a 'bit' hackish. Could you recommend a better way to do it?

0 Answers
Related