What is the difference between an untaggedImage & deletedImage in the docker source?

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

What is the difference between an untaggedImage & deletedImage in the docker source?

问题

Docker源代码定义了一个结构体,用于在运行docker image prunedocker 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"`
}

(source code link)

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.

huangapple
  • 本文由 发表于 2017年4月9日 13:54:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/43303545.html
匿名

发表评论

匿名网友

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

确定