Skip to content

Instantly share code, notes, and snippets.

@TheIndifferent
Created July 1, 2016 10:27
Show Gist options
  • Save TheIndifferent/abd80532877167e3ff1b0ce302403069 to your computer and use it in GitHub Desktop.
Save TheIndifferent/abd80532877167e3ff1b0ce302403069 to your computer and use it in GitHub Desktop.
Bash script to stop and delete all the docker containers and remove all the images
#!/bin/bash
echo 'stopping containers...'
while [[ -n "$( docker ps -a -q )" ]]
do
docker stop $(docker ps -a -q)
done
echo 'deleting containers...'
if [[ -n "$( docker ps -a -q )" ]] ; then
docker rm $(docker ps -a -q)
fi
echo 'deleting images...'
if [[ -n "$( docker images -q )" ]] ; then
docker rmi $(docker images -q)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment