英文:
What is the difference between an untaggedImage & deletedImage in the docker source?
问题
Docker源代码定义了一个结构体,用于在运行docker image prune
或docker system prune
时保存已删除的镜像:
type ImageDeleteResponseItem struct {
// 被删除的镜像的镜像ID
Deleted string `json:"Deleted,omitempty"`
// 被取消标记的镜像的镜像ID
Untagged string `json:"Untagged,omitempty"`
}
从注释中看,我不明白这两者之间的区别。难道所有被取消标记的镜像也都被删除了吗?
英文:
The docker source defines a struct to hold deleted images when running docker image prune
or docker system prune
:
type ImageDeleteResponseItem struct {
// The image ID of an image that was deleted
Deleted string `json:"Deleted,omitempty"`
// The image ID of an image that was untagged
Untagged string `json:"Untagged,omitempty"`
}
Looking at the comments I don't get the difference between the two. Aren't all untagged images also deleted?
答案1
得分: 1
不一定需要取消标记就会删除图像。如果您有一个带有多个标记的图像,取消标记将删除标记,并且图像将保留其他标记。
docker rmi first-tag
将删除 first-tag
,但仍将保留带有 second-tag
的图像。如果每次尝试删除标记时都删除整个图像,那将是灾难性的。
您可以在这里了解更多信息。
英文:
It's not necessary that untagging deletes an image. If you have an image tagged with more than one tag. It'll delete the tag and image will be there with the other tag.
docker rmi first-tag
will remove the first-tag
but will still persist the image with second-tag
. It would have been disastrous if it deleted the whole image whenever we tried to remove the tag.
You can see here for more.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论