Skip to content

Instantly share code, notes, and snippets.

@chicagobuss
Created July 12, 2017 21:15
Show Gist options
  • Select an option

  • Save chicagobuss/474bc5b1d435487f1085cbdb9f3b1dd3 to your computer and use it in GitHub Desktop.

Select an option

Save chicagobuss/474bc5b1d435487f1085cbdb9f3b1dd3 to your computer and use it in GitHub Desktop.
Docker cleanup script
#!/bin/bash
echo "Removing exited containers"
for i in $(sudo docker ps -a | grep Exit | awk '{print $1}')
do
sudo docker rm ${i}
done
echo "Removing unused images"
for i in $(sudo docker images | grep -v REPOS | awk '{print $3}')
do
sudo docker rmi ${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment