Created
September 11, 2018 18:28
-
-
Save stefanv/1a81f5867d00453c21dfb6923ac3f261 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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