Skip to main content

Remove all docker containers, images, volumes and networks

By 20 oktober 2016januari 30th, 2017No Comments

The motto nowadays seems to be: storage is cheap!

Still, in order to keep the disk space usage down, as a developer I like to remove everything docker on my machine except for the engine. In operations, servers have to run years and housekeeping is mandatory.

Remove docker state… all of it!

Containers, images, volumes, networks

# containers
docker ps -q -a | xargs docker rm</code>
<code># images</code>
<code>docker images -a -q| xargs docker rmi
# volumes</code>
<code>docker volume ls -q | xargs docker volume rm
# networks
docker network ls -q | xargs docker network rm


Where is all that stuff stored anyway?

Docker keeps all state in a directory. In debian and RedHat based systems this usually is /var/lib/docker.

So, in a server-environment with large or growing volumes, be aware that this is the place that can grow out of hand.