Reputation: 63
I'm newby in Devops culture and also eager to learn and use but I get stuck every time when i try something new and now i can't delete images. It says; it's being used by running container, stop it and then.....
See the screenshots:
Upvotes: 5
Views: 6119
Reputation: 9184
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
Upvotes: 13
Reputation: 14462
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
Upvotes: 2
Reputation: 789
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
.
Upvotes: 1