我试图建立一个共同的基础形象,我的许多其他图像将使用。但是Nerdctl/Containerd似乎不会首先在本地检查图像。
用简单的例子重现
# Dockerfile.base
FROM python:3
# Dockerfile.child
From mybase:local
输出:
PS C:\<REDACTED>\local_build_issue> nerdctl build -t mybase:local -f Dockerfile.base .
[+] Building 10.1s (5/5) FINISHED
=> [internal] load build definition from Dockerfile.base 0.1s
=> => transferring dockerfile: 55B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3 0.9s
=> CACHED [1/1] FROM docker.io/library/python:3@sha256:555f5affd32250ca74758b297f262fa8f421eb0102877596b48c0b8b464606ea 0.0s
=> => resolve docker.io/library/python:3@sha256:555f5affd32250ca74758b297f262fa8f421eb0102877596b48c0b8b464606ea 0.0s
=> exporting to oci image format 9.0s
=> => exporting layers 0.0s
=> => exporting manifest sha256:6bfdb5e41f7a1f0faf28f922e48cdd33e95b75cff958709cb7945291d34dffda 0.0s
=> => exporting config sha256:d449529a9f8347e81301101d04645624c6a52d71b0c6b85abfd8da6c65b19e31 0.0s
=> => sending tarball 9.0s
unpacking docker.io/library/mybase:local (sha256:6bfdb5e41f7a1f0faf28f922e48cdd33e95b75cff958709cb7945291d34dffda)...done
PS C:\<REDACTED>\local_build_issue> nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
mybase local 6bfdb5e41f7a About a minute ago linux/amd64 945.8 MiB 334.7 MiB
PS C:\<REDACTED>\local_build_issue> nerdctl build -t mychild:local -f Dockerfile.child .
[+] Building 0.5s (3/3) FINISHED
=> [internal] load build definition from Dockerfile.child 0.1s
=> => transferring dockerfile: 62B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> ERROR [internal] load metadata for docker.io/library/mybase:local 0.4s
------
> [internal] load metadata for docker.io/library/mybase:local:
------
Dockerfile.child:1
--------------------
1 | >>> FROM mybase:local
2 |
--------------------
error: failed to solve: mybase:local: pull access denied, repository does not exist or may require authorization: authorization status: 401: authorization failed
FATA[0000] unrecognized image format
我不知道如何让它不在docker.io上查找图像。所有关于docker cli的建议似乎都不适用或不起作用。
2条答案
按热度按时间zqry0prt1#
它实际上不能首先在本地提取图像。使用buildkitd www.example.com的nerdctl构建镜像tools.it有两种类型的后端。你可以从https://github.com/containerd/nerdctl/blob/master/docs/build.md中找到答案
a64a0gku2#
我能够通过使用“buildkit”命名空间来解决这个问题,使用Rancher Desktop和nerdctl构建第一个映像。
例如,使用示例文件构建第一个映像,如下所示:
nerdctl --namespace buildkit -t mybase:local -f Dockerfile.base .
然后第二个图像的构建应该可以工作。
nerdctl build -t mychild:local -f Dockerfile.child .
我认为本地项目是从buildkit命名空间构建的,所以你可以检查
nerdctl --namespace buildkit image ls
来查看哪些图像可以在本地使用。