docker gc (garbage collect)
Deal with orphaned docker images and old containers that fill your disk

Published: 04 May 2016

Author: Arne Schauf

Category: docker

clean all

If you are using docker you will probably encounter sooner or later that you have a lot of old containers and orphaned images that are not used by any container.

To remove those start all containers you want to keep and then run the following:

docker ps -q -a |xargs docker rm
docker images -q -a |xargs docker rmi

This will produce some errors, but that’s good and intended, as it couldn’t remove the containers that are running.

Credits go to dhrp from this thread

clean docker-compose

To remove old docker-compose run containers run

docker ps -a | grep _run_ | awk '{ print $1; }' | xargs docker rm

Published: 04 May 2016

Author: Arne Schauf

Category: docker