Skip to content

Instantly share code, notes, and snippets.

@stefanv
Created September 11, 2018 18:28
Show Gist options
  • Select an option

  • Save stefanv/1a81f5867d00453c21dfb6923ac3f261 to your computer and use it in GitHub Desktop.

Select an option

Save stefanv/1a81f5867d00453c21dfb6923ac3f261 to your computer and use it in GitHub Desktop.
#!/bin/bash
CONTAINERS=$(docker ps -aq)
IMAGES=$(docker images --filter dangling=true --quiet)
if [[ $CONTAINERS ]]; then
docker rm $CONTAINERS
else
echo "No containers to remove"
fi
if [[ $IMAGES ]]; then
docker rmi $IMAGES
else
echo "No dangling images to remove"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment