How To Remove Docker Image, Volumes & Container In Linux

How To Remove Docker, I’m having some docker images downloaded from the docker hub & I will delete images & container on the server. you can remove docker unused images by force using the name.

Check Out: Find IpAddress of a container

How To Remove Docker Image, Volumes & Container:

Check all the images on docker-machine using docker images

How To Remove Docker

Use this command to remove the images using docker rmi image_name

I have already created a MySQL container if you don’t know how to create a container check it out Create Container here.

docker ps 

 docker remove unused images

Check Out: Create Apache Docker Image Using Docker file

Here are two containers running, I will remove MySQL container here, first, you will have to stop the to container before deleting it.

Removing Volumes

List all the volumes using docker volume ls

you can remove the volumes using docker volume rm volum_name1 volum_name

If you have removed a container but the volume is not removed, it’s not connected to any container.

we can check using docker volume ls -f dangling=true

Remove dangling volume using docker volume prune 

Remove Container

you have to stop the container before removing it.

docker stop 78e701a98334

you can see I have stopped the container & checked the running container & delete it with Container ID as shown in below figure

Check all the running container using docker ps -a and if you want to run a container and automatically delete when exists, then use this command to create docker run –rm image_name

Remove the container with conditions using docker rm $(docker ps -a -f status=exited -q)

Now See there is only one container running,

Check Out: How To Mount Volume To Apache Container In Docker

Remove Container Images

Here I have deleted the image of MySQL,

docker rmi 8b6ff3f79840 

As you can see after deleting the image of MySQL. There is no MySQL image available.

Removing all unused Images, Networks, Containers, and Volumes for both dangling and unreferenced. 

docker system prune 

If you run the below command, it will remove all unused images not just dangling.

docker system prune -a

YouTube Link: Remove Docker Images

That’s it. Docker remove images force by name unused

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment