From 73680961a0daf21266290ef1bf17ceaac3bbf7d2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 1 Aug 2023 08:13:17 -0400 Subject: [PATCH] bring back docker-cleanup file just for safekeeping --- .../shell/bash/scripts/docker-cleanup.sh | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 modules/common/shell/bash/scripts/docker-cleanup.sh diff --git a/modules/common/shell/bash/scripts/docker-cleanup.sh b/modules/common/shell/bash/scripts/docker-cleanup.sh new file mode 100755 index 0000000..b2f3cab --- /dev/null +++ b/modules/common/shell/bash/scripts/docker-cleanup.sh @@ -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 "^"; then + docker rmi "$(docker images | grep "^" | awk '{print $3}')" +else + echo "No untagged docker images." +fi + +echo "Cleaned up docker."