Skip to content

Not finding local images that do exist, trying to pull instead #42893

Description

@jeffparsons

Description

When BuildKit is enabled, if you tag an image with --tag and then refer to it when building another image, Docker will not find it and instead tries to pull it from Docker Hub.

Disabling BuildKit makes the problem go away.

Steps to reproduce the issue:

Make these files:

Dockerfile.parent:

FROM rockylinux/rockylinux:8.4@sha256:8122f31fbdd5c1368c6b7d5b9ae99fec2eb5966a5c967339d71e95c4a3ab7846

RUN echo "Installing common stuff"

CMD echo "Everything is good"

Dockerfile.child:

FROM local/foo-parent

RUN echo "Installing special stuff"

The run these commands:

docker build -f Dockerfile.parent -t local/foo-parent .
docker build -f Dockerfile.child -t local/foo-child .

Describe the results you received:

On building the parent image, the last line says:

 => => naming to docker.io/local/foo-parent                                                     0.0s

On building the child image, it fails to find the local image and instead tries to pull from Docker Hub:

 => ERROR [internal] load metadata for docker.io/local/foo-parent:latest                        2.9s

Describe the results you expected:

The tag I specified already had a / in it, so Docker shouldn't have automatically prefixed it with docker.io/. I guess that's at least part of the problem?

However, docker inspect still finds the image just fine by either name, so I'm not sure why building the child image fails to find it.

jeff@tank docker-local-image-woes % docker inspect docker.io/local/foo-parent:latest
[
    {
        "Id": "sha256:358eed8be7a681d6b130631dab99dfe0b46635116be03d1691dfc8a04c0301a3",
        "RepoTags": [
            "local/foo-parent:latest"
        ],
jeff@tank docker-local-image-woes % docker inspect local/foo-parent                 
[
    {
        "Id": "sha256:358eed8be7a681d6b130631dab99dfe0b46635116be03d1691dfc8a04c0301a3",
        "RepoTags": [
            "local/foo-parent:latest"
        ],

Additional information you deem important (e.g. issue happens only occasionally):

I'm running Docker Desktop on an M1 MacBook.

Output of docker version:

Docker version 20.10.8, build 3967b7d

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.6.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-rc.3)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 9
 Server Version: 20.10.8
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e25210fe30a0a703442421b0f60afac609f950a3
 runc version: v1.0.1-0-g4144b63
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.47-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 2.922GiB
 Name: docker-desktop
 ID: GJTR:EIL2:CYN3:JRV6:5JXM:VS3U:HRAU:2VA6:WUBG:MDN7:VXF6:24AO
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

Physical MacBook with Apple Silicon (M1), default settings, relatively fresh install of everything including Docker. (This is my first time trying to get an existing project working on the new Macs.)

This is all pure ARM -- no x86_64 virtualisation or anything complicating it as far as I can tell:

jeff@tank docker-local-image-woes % docker inspect rockylinux/rockylinux:8.4@sha256:8122f31fbdd5c1368c6b7d5b9ae99fec2eb5966a5c967339d71e95c4a3ab7846 | grep Architecture
        "Architecture": "arm64",
jeff@tank docker-local-image-woes % docker inspect local/foo-parent | grep Architecture
        "Architecture": "arm64",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions