Difference between docker rm IMAGE vs docker rmi IMAGE

Viewed 8025

According to Docker documentations, docker image rm "Remove one or more images" [1]. docker rmi has a same description [2], but then it goes on to say "Removes (and un-tags) one or more images from the host node."

Do docker image rm IMAGE and docker rmi IMAGE have an identical effect under any scenario? IMAGE is ID of the particular image that is to be removed.

3 Answers

The man page for docker rmi specifies that docker rmi is an alias for docker image rm. I suppose the documentation from docker is a little bit inconsistent in that regard. They write all the details for docker rmi while the documentation for docker image rm is lackluster.

It looks like docker rm is for containers and docker rmi is for images.

PS C:\Users\3des> docker rm httpd --force
Error: No such container: httpd
PS C:\Users\3des> docker rm httpd
Error: No such container: httpd
______________________________________________
PS C:\Users\3des> docker rmi httpd --force
Untagged: httpd:latest
Untagged: httpd@sha256:2fab99fb3b1c7ddfa99d7dc55de8dad0a62dbe3e7c605d78ecbdf2c6c49fd636
``


  

1). The docker image rm command "Remove one or more containers" not container image. to check for container and its ID "docker ps -a" command

2). However, the docker rmi command means rm = remove i = image. it is used to removing docker images. remembers that containers are created from images. the "docker images or docker image ls" shows images, repository, TAG, and image ID. docker rmi <image_ID> to remove image. NOTE even when it is possible to create a new image from the existing image using the "docker commit" command, such image will come it its unique image id.

Related