![docker remove container docker remove container](https://net2.com/wp-content/uploads/2021/06/docker.jpg)
We should always remove dependent containers first although we can forcefully remove image by using -f. Once all the dependent containers are removed, we can safely delete image by running command docker rmi Output for image removal command So, let’s first remove this container by using below command: docker rm Remove the referenced container We have highlighted container in the reference.
![docker remove container docker remove container](https://miro.medium.com/max/1400/1*2mSWZRxw_9NDHcZtJr2dmA.png)
We can verify by running below command to show container history: docker ps -a Referenced container in the image deletion command We can clearly see that one of the containers is dependent on it. If we issue docker rmi command, we would see an error message like this: docker rmi mogo/ubuntu:telnet Error while removing images Then lets’ say we want to delete image mogo/ubuntu:telnet. First we can identify images on our machine using below command: docker images List docker images on the machine You would likely see an error message which resembles following:Įrror response from daemon: conflict: unable to remove repository reference “mogo/ubuntu:telnet” (must force) – container 4888c45aa31c is using its referenced image a955c52ec9ecĮrror: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
![docker remove container docker remove container](https://huongdanjava.com/wp-content/uploads/2018/02/remove-container-in-docker-2.png)
You cannot delete an image if it has been used to spawn containers or child images based on it. For this we have to use the command: docker rmi IMAGE You can remove an image using its short or long ID, its tag, or its digest in the Docker.