Last active
August 29, 2015 14:03
-
-
Save spuder/8fe4ca4b0643e800f3ca to your computer and use it in GitHub Desktop.
Docker Cleanup for mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functions to clean up docker containers on mac | |
# Based on this blog article, however is more mac friendly (no xargs -r) | |
# http://blog.stefanxo.com/2014/02/clean-up-after-docker/ | |
# Searches for images and containers that are named/tagged with '<none>' and removes them | |
# If no results, prints out the usage information | |
#Create functions since aliases don't play nicely with subshells | |
dci() { | |
docker rmi $(docker images --no-trunc | awk '$2 == "<none>" {print $3}') | |
} | |
dcc() { | |
#docker rm $(docker ps -a --no-trunc | awk '$5 == "Exit" {print $1}') | |
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm | |
} | |
dce() { | |
# rm all containers with 'exit' status | |
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker rm | |
} | |
alias dockerclean="dce; dcc; dci" | |
alias d="docker" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment