解决删除镜像时image is referenced in multiple repositories

1、查看镜像 docker images

rt@123:~# docker images
REPOSITORY                                  TAG                 IMAGE ID            CREATED             SIZE
192.168.0.1/jii/jenkins                    1.0.1              3391ef1391f6        18 hours ago        206 MB
192.168.0.1/you/tom                        1.0.8              f8ab12e03d53        22 hours ago        276 MB
192.168.0.1/you/tom                        1.0.9              f8ab12e03d53        22 hours ago        276 MB

2、删除镜像,会报错

rt@123:~# docker rmi f8ab12e03d53
Error response from daemon: conflict: unable to delete f8ab12e03d53 (must be forced) - image is referenced in multiple repositories

仔细观察,发现f8ab12e03d53这个镜像id指向了两个repository,因此无法删除

3、删除时可以用repository和tag的方式来删除

rt@123:~# docker rmi 192.168.0.1/you/tom:1.0.8
Untagged:192.168.0.1/you/tom:1.0.8
 

4、再次查看镜像,1.0.8的就被删除了。

rt@123:~# docker images
REPOSITORY                                  TAG                 IMAGE ID            CREATED             SIZE
192.168.0.1/jii/jenkins                    1.0.1              3391ef1391f6        18 hours ago        206 MB
192.168.0.1/you/tom                        1.0.9              f8ab12e03d53        22 hours ago        276 MB

1.停止所有的container,这样才能够删除其中的images:

docker stop $(docker ps -a -q)

如果想要删除所有container的话再加一个指令:

docker rm $(docker ps -a -q)

2.查看当前有些什么images

docker images

3.删除images,通过image的id来指定删除谁

docker rmi

想要删除untagged images,也就是那些id为的image的话可以用

docker rmi $(docker images | grep "^" | awk "{print $3}")

要删除全部image的话

docker rmi $(docker images -q)

你可能感兴趣的:(K8S)