Docker: remove all containers and images

By | 13/04/2016

This post just as a reminder how to delete all containers and images. While experimenting with Docker I continuously needs these commands and instead of always Googling them I might be better of just writing a small post.

Remove all containers

root@ubuntu-demo:/home/cloud-user# docker rm `docker ps -qa`

Remove all images

root@ubuntu-demo:/home/cloud-user# docker rmi $(docker images -q)

Remove all ghost images from Docker-Machine

Sometimes the creation of a host fails and it leaves a ghost entry when doing “docker-machine ls”. Below command will completely remove all hosts so be careful when using it.

root@ubuntu-demo:/home/cloud-user# docker-machine rm -f $(docker-machine ls -q);

Leave a Reply

Your email address will not be published. Required fields are marked *