Docker rmi unable to remove images
Answer a question
So , I have a bunch of untagged images on my host. I use
sudo docker rmi $(sudo docker images | grep "<none>" | awk '{print($3)}') to delete these images. On execution , I get error
Error response from daemon: Conflict, cannot delete 31fa814ba25a because the container 70c20aa2c19f is using it, use -f to force
So I do a
sudo docker rmi 70c20aa2c19f
on which I get the error
Error response from daemon: No such image: 70c20aa2c19f
So if there's no image with ImageID 70c20aa2c19f , then why the initial delete command's error states that there is an image with ImageID 70c20aa2c19f ?
Answers
As the comments on your question indicate, you have figured out that you need to use:
docker rmito remove imagesdocker rmto remove containers
for a bit more background: there is a difference between:
- A docker image,
- A running container based off that image and
- A stopped container based off that image
The stopped container is kept because running the container might have changed the file system in the container, you can then commit this stopped container to have a new image. (that's one way to create images, manually run the commands and commit the resulting container).
Creating images using docker build and Dockerfile, does the same thing, it runs the container executing the Dockerfile commands and commits the resulting images, only tagging the last image that was committed.
更多推荐



所有评论(0)