docker image刪不掉的問題

在使用Docker的時候遇到刪不掉image的情況,如下:

root@ubuntu:/opt/docker# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
door/ubuntu-nginx   v2                  5e4f2da203e2        5 minutes ago       283.3 MB
<none>              <none>              46987ed2da40        33 minutes ago      129 MB
<none>              <none>              20248c31e1a2        45 minutes ago      129 MB
door/ubuntu-nginx   v1                  0e35a55569f5        About an hour ago   280.8 MB
ubuntu              latest              104bec311bcd        2 weeks ago         129 MB
hello-world         latest              c54a2cc56cbb        6 months ago        1.848 kB
root@ubuntu:/opt/docker# docker rmi 5e4f2da203e2
Error response from daemon: conflict: unable to delete 5e4f2da203e2 (must be forced) - image is being used by stopped container 06622513ce3c

解決方法:

  1. 先查詢記錄 docker ps -a
  2. 把該鏡像的記錄全部刪除掉,如果刪除所有鏡像的記錄,可以使用:docker ps -a|awk '{print $1}'|xargs docker rm
  3. docker rmi 5e4f2da203e2就可以了

網上還有網友使用service docker restrat 之後再刪,本人試了一下不管用,可能是因爲環境不一樣,哈哈!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章