Deleting Docker Files to Free up Space in your Disk

Last updated:

HEADS-UP If you get error messages such as Cannot connect to the Docker daemon. Is the docker daemon running on this host? you may need to add sudo to the commands!

Delete all Images

$ docker rmi -f $(docker images -q)

Or, alternatively, using sudo:

$ sudo docker rmi -f $(sudo docker images -q)

Delete Dangling (unused) Images

$ docker rmi $(docker images --quiet --filter "dangling=true")

Delete all Containers

$ docker rm $(docker ps -aq)

Delete all Stopped containers

$ docker rm $( docker ps -q -f status=exited)

See also

Dialogue & Discussion