Skip to content

Instantly share code, notes, and snippets.

@CamiloBernal
Forked from urodoz/clean_docker.sh
Created December 8, 2016 13:38
Show Gist options
  • Save CamiloBernal/c7e23c67199d74987c5aab34e50018f6 to your computer and use it in GitHub Desktop.
Save CamiloBernal/c7e23c67199d74987c5aab34e50018f6 to your computer and use it in GitHub Desktop.
Cleans the old images and exited containers
# Clean the exited containers
docker rm $(sudo docker ps -a | grep Exit | cut -d ' ' -f 1)
# Clean the untagged images (or old images)
docker rmi $(docker images | tail -n +2 | awk '$1 == "<none>" {print $'3'}')
# On Docker 1.9+ you can remove the orphan volumes with the next command
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