【发布时间】:2023-01-14 09:22:02
【问题描述】:
如果使用的图像有多个图像标签,docker image prune -a 将保留按字母顺序排列的最后一个标签。请参阅底部的可重现示例。
有没有办法影响保留哪些标签?理想情况下,我希望 docker image prune -a 保留所有正在使用的图像标签组合(正在使用的包括停止的容器)。
可重现的示例(小心,因为它会从您的 docker 系统中删除图像):
# docker image prune -a keeps hellow-world:x
docker pull hello-world
docker tag hello-world:latest hello-world:x
docker tag hello-world:latest hello-world:a
docker run hello-world:x
docker run hello-world:a
docker image prune -a
# Reset
docker system prune -a
# docker image prune -a keeps hellow-world:z
docker pull hello-world
docker tag hello-world:latest hello-world:x
docker tag hello-world:latest hello-world:z
docker run hello-world:x
docker run hello-world:z
docker image prune -a
【问题讨论】:
-
我认为这个问题与 moby 项目中关于“docker image prune/rm removes in-use docker tags”的开放问题有关github.com/moby/moby/issues/36295
-
是的,图像仍然存在,但即使对于正在运行的容器,图像标签组合也会被删除。
标签: docker