DEV Community

Discussion on: Understanding Docker: part 4 – Docker images

Collapse
 
bluefire153 profile image
Tien Do • Edited

In order to remove docker image, you need to stop all containers which related to that image first, don't you?

Collapse
 
aurelievache profile image
Aurélie Vache

Yes if you try to remove an image and a running container exists, rmi command will not be a success.

BUT you can force a remove image command :-) :

$ docker rmi ubuntu:latest
Error response from daemon: conflict: unable to remove repository reference "ubuntu:latest" (must force) - container 988cb10f88b8 is using its referenced image f643c72bc252

$ docker rmi ubuntu:latest --force
Untagged: ubuntu:latest
Untagged: ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c