英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论