mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-14 03:42:56 +00:00
27 lines
600 B
Plaintext
27 lines
600 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
# Stop all containers
|
||
|
if [ "$(docker ps -a -q)" ]; then
|
||
|
echo "Stopping docker containers..."
|
||
|
docker stop $(docker ps -a -q)
|
||
|
else
|
||
|
echo "No running docker containers."
|
||
|
fi
|
||
|
|
||
|
# Remove all stopped containers
|
||
|
if [ "$(docker ps -a -q)" ]; then
|
||
|
echo "Removing docker containers..."
|
||
|
docker rm $(docker ps -a -q)
|
||
|
else
|
||
|
echo "No stopped docker containers."
|
||
|
fi
|
||
|
|
||
|
# Remove all untagged images
|
||
|
if [[ $(docker images | grep "^<none>") ]]; then
|
||
|
docker rmi $(docker images | rg "^<none>" | awk '{print $3}')
|
||
|
else
|
||
|
echo "No untagged docker images."
|
||
|
fi
|
||
|
|
||
|
echo "Cleaned up docker."
|