Skip to content

Instantly share code, notes, and snippets.

@richarvey
Last active August 18, 2017 10:25
Show Gist options
  • Save richarvey/3b47273e646da9351bcb5bca02e34a2a to your computer and use it in GitHub Desktop.
Save richarvey/3b47273e646da9351bcb5bca02e34a2a to your computer and use it in GitHub Desktop.
clean_up_docker

Remove all stopped containers.

docker rm $(docker ps -a -q)

This will remove all stopped containers by getting a list of all containers with docker ps -a -q and passing their ids to docker rm. This should not remove any running containers, and it will tell you it can’t remove a running image.

Remove all untagged images

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

Remove all images from named repository

docker rmi $(docker images --filter=reference='richarvey/*')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment