Skip to content

Instantly share code, notes, and snippets.

@dgreda
Last active May 12, 2017 06:49
Show Gist options
  • Save dgreda/b195f4e782b618571db19e8fa45a085a to your computer and use it in GitHub Desktop.
Save dgreda/b195f4e782b618571db19e8fa45a085a to your computer and use it in GitHub Desktop.
Docker Helpers

Remove all exited containers

sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm

or

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

Remove all untagged images

docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")

Clean up Docker.qcow2

WARNING: it deletes all stopped containers, all volumes not used by at least one container and all images without at least one referring container.

docker system prune
docker run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n fstrim /var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment