mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 14:35:37 +00:00
bring back docker-cleanup file
just for safekeeping
This commit is contained in:
parent
c59e914430
commit
73680961a0
26
modules/common/shell/bash/scripts/docker-cleanup.sh
Executable file
26
modules/common/shell/bash/scripts/docker-cleanup.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/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 -q "^<none>"; then
|
||||
docker rmi "$(docker images | grep "^<none>" | awk '{print $3}')"
|
||||
else
|
||||
echo "No untagged docker images."
|
||||
fi
|
||||
|
||||
echo "Cleaned up docker."
|
Loading…
Reference in New Issue
Block a user