Docker使用WORKDIR构建时,启用Containerd beta会导致Docker在本地无法找到镜像。

huangapple go评论63阅读模式
英文:

Docker build with WORKDIR makes Docker unable to find the image locally with Containerd beta enabled

问题

# syntax=docker/dockerfile:1
FROM rockylinux:9

WORKDIR /opt/deploy
export DOCKER_BUILDKIT=1
docker build --platform linux/amd64 -t minimal:test -f Dockerfile .
export DOCKER_BUILDKIT=1
docker run --rm --platform linux/amd64 -it minimal:test
Unable to find image 'minimal:test' locally
docker: Error response from daemon: failed to resolve reference "docker.io/library/minimal:test": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed.
See 'docker run --help'.
$ docker --version
Docker version 20.10.22, build 267d2e5
英文:

Minimal Dockerfile in ./Dockerfile:

# syntax=docker/dockerfile:1
FROM rockylinux:9

WORKDIR /opt/deploy

Build works fine:

export DOCKER_BUILDKIT=1
docker build --platform linux/amd64 -t minimal:test -f Dockerfile .

Run does not:

export DOCKER_BUILDKIT=1
docker run --rm --platform linux/amd64 -it minimal:test

Error:

Unable to find image 'minimal:test' locally
docker: Error response from daemon: failed to resolve reference "docker.io/library/minimal:test": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed.
See 'docker run --help'.

Meanwhile, I can clearly see minimal:test in the output from docker image ls, and I can successfully run docker image rm minimal:test.

Weirder still, if I comment out the WORKDIR line, it works fine!

What am I dong wrong here?

I'm using Docker Desktop for Mac on MacOS 12.4:

$ docker --version
Docker version 20.10.22, build 267d2e5

Edit: I had the containerd beta option enabled in Docker Desktop, which turned out to be the problem. Adding this to make it easier to search for this issue in the future.

答案1

得分: 0

以下是翻译好的部分:

"Empirically, this turned out to be a bug in the experimental 'Containerd' option in Docker Desktop, possibly related to lazy-loading of images. Disabling that option and restarting the Docker daemon fixed the problem." 可以翻译为:

"经验上看,这实际上是Docker Desktop中实验性的'Containerd'选项中的一个错误,可能与镜像的延迟加载有关。禁用该选项并重新启动Docker守护程序可以解决这个问题。"

英文:

Empirically, this turned out to be a bug in the experimental "Containerd" option in Docker Desktop, possibly related to lazy-loading of images. Disabling that option and restarting the Docker daemon fixed the problem.

huangapple
  • 本文由 发表于 2023年5月11日 02:00:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76221379.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定