Last active
January 18, 2021 09:15
-
-
Save takakd/9cf0cb928ef8ada7e0dc13d1de9a8a79 to your computer and use it in GitHub Desktop.
Docker snnipets.
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
# Stop all containers | |
docker stop $(docker ps -q) | |
# Remove all containers | |
docker rm $(docker ps -q -a) | |
# Remove all images | |
$ docker rmi $(docker images -q) | |
# Cleanup all docker containers | |
PROCESS_STATUS=$(docker ps -a --format "{{.ID}} {{.Image}} {{.Names}}" --filter "Name=^docker_") | |
IDS=$(echo "${PROCESS_STATUS}" | cut -f1 -d " ") | |
IMAGES=$(echo "${PROCESS_STATUS}" | cut -f2 -d " ") | |
if [[ "$PROCESS_STATUS" = "" ]]; then | |
echo "no containers." | |
fi | |
docker rm ${IDS} | |
docker rmi -f ${IMAGES} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment