Skip to content

Instantly share code, notes, and snippets.

@Pelirrojo
Forked from beeva-manueldepaz/killAllContainers.sh
Last active August 20, 2017 19:23
Show Gist options
  • Save Pelirrojo/162717532e798546bd3734b902ca5e9c to your computer and use it in GitHub Desktop.
Save Pelirrojo/162717532e798546bd3734b902ca5e9c to your computer and use it in GitHub Desktop.
Script to stop and delete current running containers (useful to work with DevLab) or even images (commented by default)
#!/bin/sh
# [DevLab](https://github.com/TechnologyAdvice/DevLab)
# $sudo mv /path/to/killAllContainers.sh /usr/local/bin/killAllContainers
# $sudo chmod a+x /usr/local/bin/killAllContainers
read -p "This will stop and delete all running containers. Are you sure that you want to continue? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
#docker rmi $(docker images -q)
#docker rmi $(docker images -q --filter "dangling=true")
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment