Unable to delete docker images

Viewed 5141
3 Answers

Get running containers

docker ps

Get all running and stopped container

docker ps -a

Stop single container

docker stop <container_id>

Stop all containers

docker stop $(docker ps -aq)

Remove single container

docker rm <container_id>

Remove all containers

docker rm $(docker ps -aq)

Remove single image

docker rmi <image_id>

Remove all images

docker rmi $(docker images -q)

Remove everything from Docker host machine(use with caution because will delete everything like images, containers,networks etc)

docker system prune

You can just force remove the image even when there is a container that is still using it, if you don't mind doing that.

docker image rm <image-name> --force

Best way to delete all stopped containers is

docker container prune 

As for the running containers, you should be able to list them with

docker container ls 

add (--all) to see all (running/stopped) containers

docker container ls --all

Use docker ps -a to list all your running containers. You will find the ones still running. Stop them by using docker stop NAMEOFTHECONTAINER and remove them with docker rm NAMEOFTHECONTAINER.

Related