Skip to content
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

Can't load base image from local docker images without registry #1453

Closed
agirault opened this issue Dec 6, 2022 · 3 comments
Closed

Can't load base image from local docker images without registry #1453

agirault opened this issue Dec 6, 2022 · 3 comments

Comments

@agirault
Copy link

agirault commented Dec 6, 2022

Related threads

Issue

We call the following command as it is the recommended step to test a container image before pushing it to a registry:

$ docker buildx build --platform $SINGLEARCH -t my_base_image --load .

A single platform build result will be exported to docker images, as documented:

$ docker images --format '{{.Repository}}' | grep my_base_image
my_base_image

Consider then this simple file named final.dockerfile:

# syntax=docker/dockerfile:1
ARG BASE_IMAGE
FROM $BASE_IMAGE as base

We attempt to build this image using my_base_image as a base image with the command below:

docker buildx build --platform $SINGLEARCH -f final.dockerfile --build-arg BASE_IMAGE=my_base_image . 

Unlike docker build, this will attempt to reach a registry (docker.io/library if there isn't one in the tag name) without using the cached image in docker images:

> [$SINGLEARCH internal] load metadata for docker.io/library/my_base_image:latest:
------
final.dockerfile:3
--------------------
   1 |     # syntax=docker/dockerfile:1
   2 |     ARG BASE_IMAGE
   3 | >>> FROM $BASE_IMAGE as base
   4 |     
--------------------
ERROR: failed to solve: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

The issue is similar if there is a registry url in the image name:

ERROR: failed to solve: your_registry.io: not found

Using docker build instead of buildx is not possible when building for another platform than the host platform.

Questions

  1. How do we use a docker image on the client (docker images) as a base image for a new single-arch buildx build?
  2. If that's not possible from --load/--output=type=docker, can it be done with another client-side output type (local, tar, oci) without requiring a registry?
    • @jjlin suggested using a local registry here but it can open up other issues and might not be an acceptable solution for some
@crazy-max
Copy link
Member

This is expected as your container builder does not have access to the docker store. This will be solved with the containerd snapshotter on docker, see docker/roadmap#371. This is also similar to #166. In the meantime you can push this image to a registry.

Also if you just want to build a single platform you can just use the default docker builder:

$ docker buildx use default
$ docker buildx build --platform linux/amd64 -t my_base_image .
$ docker buildx build --platform linux/amd64 -f final.dockerfile --build-arg BASE_IMAGE=my_base_image . 

@jiangtao69039
Copy link

I'm running into the same issue. Is there any solution now? @agirault

@jedevc
Copy link
Collaborator

jedevc commented Oct 13, 2023

This issue is a duplicate of moby/buildkit#2343, so I'm going to close this issue in preference of that one - that one also has more discussion there.

@jedevc jedevc closed this as completed Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants