Skip to content

Instantly share code, notes, and snippets.

@kalopilato
Last active July 8, 2017 03:31
Show Gist options
  • Save kalopilato/e9f28f5b79cd811d71c7eb0ed2f57a83 to your computer and use it in GitHub Desktop.
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
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
@kalopilato
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment