Last active
July 8, 2017 03:31
-
-
Save kalopilato/e9f28f5b79cd811d71c7eb0ed2f57a83 to your computer and use it in GitHub Desktop.
Quick cleanup script when working with multiple docker containers in multiple tmux sessions/windows/panes
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
CONTAINERS=`docker ps -a -q` | |
if [[ ! -z $CONTAINERS ]] | |
then | |
echo "Stopping all docker containers..." | |
docker stop $CONTAINERS | |
echo "Removing all docker containers..." | |
docker rm $CONTAINERS | |
else | |
echo "No docker containers to clean up!" | |
fi | |
echo "bye bye tmux" | |
tmux kill-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget to set permissions:
chmod u+x docker-tmux-cleanup.sh
and maybe alias it in your .bash_profile/.zshrc
alias docker-cleanup=path/to/docker-tmux-cleanup.sh