Skip to content

Instantly share code, notes, and snippets.

@etiennemarais
Last active July 18, 2018 14:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etiennemarais/fcda8a3c02c4ae64c511ab805608ad80 to your computer and use it in GitHub Desktop.
Save etiennemarais/fcda8a3c02c4ae64c511ab805608ad80 to your computer and use it in GitHub Desktop.
Quick alias to remove and clean untagged docker images and stopped containers.
#
# Credit to http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html
#
# Add this to your bash profile.
#
clean_docker () {
# Remove stopped containers
docker rm $(docker ps -a -q);
# Remove untagged images
docker rmi $(docker images | grep "^<none>" | awk "{print $3}");
# Remove dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment