gpt4 book ai didi

Docker 在删除图像后拉取图像,除最后一层外的所有层都已经存在

转载 作者:行者123 更新时间:2023-12-02 18:18:36 27 4
gpt4 key购买 nike

拉取前,docker images中的信息:

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
weaveworks/weave-kube 2.5.2 f04a043bb67a 7 months ago 148MB
weaveworks/weave-npc 2.5.2 5ce48e0d813c 7 months ago 49.6MB
k8s.gcr.io/kube-proxy-amd64 v1.11.0 1d3d7afd77d1 18 months ago 97.8MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 2 years ago 742kB

但是,当我尝试下载图像时,它显示除最后一层之外的所有层都已经存在:

$ docker pull image_name:s2-audio-1
s2-audio-1: Pulling from image_name:s2-audio-1
121er07f4eba: Already exists
0c8f4rew94dc: Already exists
198ef12987c0: Already exists
1pp1b5eaa295: Already exists
8a4fm1842a93: Already exists
3446a509a6e7: Already exists
10h6cedf3c5e: Already exists
0te381950737: Already exists
6gdf14004bd1: Already exists
88le96f02ad0: Already exists
udhb049fbae0: Already exists
llae95975878: Already exists
9fl1d0e8bd4e: Already exists
jd3b2c426fa1: Already exists
6j10b5462122: Already exists
21c258fef3cc: Already exists
0jzb3ee699a9: Already exists
zj019b962h6a: Already exists
04345388691c: Already exists
eyu517086e97: Pull complete
Digest: sha256:9wk43b75202a889711817b52e5979fg33ed387727a7a6eddc8e521d1da05ld2a
Status: Downloaded newer image for image_name:s2-audio-1

我猜想docker state有一些问题,所以我尝试通过以下方式解决问题:

sudo service docker stop
sudo rm -rf /var/lib/docker
sudo service docker start

然后我就可以正常拉image_name:s2-audio-1了。

s2-audio-1: Pulling from image_name:s2-audio-1
121er07f4eba: Pull complete
0c8f4rew94dc: Pull complete
198ef12987c0: Pull complete
1pp1b5eaa295: Pull complete
8a4fm1842a93: Pull complete
3446a509a6e7: Pull complete
10h6cedf3c5e: Pull complete
0te381950737: Pull complete
6gdf14004bd1: Pull complete
88le96f02ad0: Pull complete
udhb049fbae0: Pull complete
llae95975878: Pull complete
9fl1d0e8bd4e: Pull complete
jd3b2c426fa1: Pull complete
6j10b5462122: Pull complete
21c258fef3cc: Pull complete
0jzb3ee699a9: Pull complete
zj019b962h6a: Pull complete
04345388691c: Pull complete
eyu517086e97: Pull complete
Digest: sha256:9wk43b75202a889711817b52e5979fg33ed387727a7a6eddc8e521d1da05ld2a
Status: Downloaded newer image for image_name:s2-audio-1

但是,当我试图删除这张图片时:

Untagged: image_name:s2-audio-1
Untagged: image_name@sha256:9wk43b75202a889711817b52e5979fg33ed387727a7a6eddc8e521d1da05ld2a
Deleted: sha256:d7349f1dd8yhdffb55b9c68ec2f4573e6e45d6f22bd065e940d6e8f06627f586
Deleted: sha256:2da3218b4cd1a85e388k4b435411ac1082ce23571eeea4570a230583ee34795a

未标记和删除层的数量比以前少得多。应该是这样的:

$ docker rmi image_name:s2-audio-3
Untagged: image_name:s2-audio-3
Deleted: sha256:eds287df3d80dc048096dd67ecf09008b99dbe23ht8a6d4244e82ht9e0620c6d
Deleted: sha256:0d387c6877f0382a8d62474f1fdc3alo44cb1159fdcd3b7fdd9fb0c4f61d32a8
Deleted: sha256:d1b2f94b32ec9a4be182fcb4ef4919f439v6b6765975295654a3e594daa24646
Deleted: sha256:2f9uug161f8c01723367a21121797400261d41426a0dbd2a1c85828df7851bb8
Deleted: sha256:a6865f228367ce14548da56a9d9bbe5568sf6b30eb6de04bf46a758356d93280
Deleted: sha256:fc47aad0131dca88bd2ads792f238c577594a7b0e27f678cea0e64f447c94b44
Deleted: sha256:11e5f8ad0b20ebaa39c17273a859wr32a9260dafea5e513850ec56106ede679a
Deleted: sha256:cabf7d90af0bew5c5ce4965a8e994146fed9114f32b3da9bab321963c63ea308
Deleted: sha256:c7cfdc043db5f78arfg7a660f60642d8d6f4de770c10089f3dc5b3d989e856dd
Deleted: sha256:30a82effba73451b0c235859724995cebfe3g6574d286ffe5c2beb74150b977f
Deleted: sha256:7eae8b82dd96e5bde4c23a5868222c7eae05f2743c608d44dffdfbed54c56ef0
Deleted: sha256:b9ca36ae1e9e7e201802597f6e434adc5533sdsc90d9ab0476502b1cf5bd5ee4
Deleted: sha256:a765c11dsbbfc69f1089f96e55ed02a901e35c1f2834cebc790a2046fe5dcaf1

然后又尝试拉取image_name:s2-audio-1,拉取问题再次出现。 (即除了最后一层之外的所有层都已经存在。)

现在,每当我删除任何图像时,Docker 只会删除和取消标记一层。即使我使用 docker images,剩余的图层仍然保存在磁盘中并且不可见:

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
weaveworks/weave-kube 2.5.2 f04a043bb67a 7 months ago 148MB
weaveworks/weave-npc 2.5.2 5ce48e0d813c 7 months ago 49.6MB
k8s.gcr.io/kube-proxy-amd64 v1.11.0 1d3d7afd77d1 18 months ago 97.8MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 2 years ago 742kB

这让我很担心,因为不可见的图层占用了我大量的存储空间,而且没有合适的方法删除它们。 (sudo rm -rf/var/lib/docker 始终不是一个好主意。)

最佳答案

正在运行 docker image rm <image> (或等效的 docker rmi <image> )实际上只是取消标记图像并删除最后一层。其他图层将保留在原位,因为它们可能会被其他图像重复使用。

如果你想删除这些“悬挂”层(标记图像不再使用的层),你可以使用 docker image prune 命令。

您可以通过运行列出悬挂层:

docker image ls --filter dangling=true

关于Docker 在删除图像后拉取图像,除最后一层外的所有层都已经存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59472202/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com