I recently started using Docker and never realized that I should use docker-compose down
instead of ctrl-c
or docker-compose stop
to get rid of my experiments. I now have a large number of unneeded docker images locally.
Is there a flag I can run to delete all the local docker images & containers?
Something like docker rmi --all --force
--all flag does not exist but I am looking for something with similar idea.
Easy and handy commands
To delete all images
To delete containers which are in exited state
To delete containers which are in created state
NOTE: Remove all the containers then remove the images
To delete all containers including its volumes use,
To delete all the images,
Remember, you should remove all the containers before removing all the images from which those containers were created.
In case you are working on Windows (Powershell),
To delete all images :
where -a is all, and -q is return only image ids
To remove unused images, and containers :
beware as if you are using docker swarm, and your local machine is joining remote swarm (as manager/worker), your local will be the deployed repo. executing this thus removes the deployed images.
docker image prune -a
Local docker version: 17.09.0-ce, Git commit: afdb6d4, OS/Arch: darwin/amd64
To simple clear everything do:
Everything means:
Another way with
xargs