diff options
author | Oliver Smith <osmith@sysmocom.de> | 2022-02-11 13:37:23 +0100 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2022-02-11 15:44:44 +0100 |
commit | 88521fbc14d085d7fa43191ffb083e1254227fcc (patch) | |
tree | 3661cb0be1275f669fe0280150a6e2a973a02b91 | |
parent | b5ebf6ea6b14b85fee114b78d280549f27d460f1 (diff) |
scripts/docker-cleanup.sh: conditional img clean
Only run the simple image clean code if docuum is not running. It works
well enough in most cases, but has the drawbacks that it never deletes
"latest" images or images not matching "^osmocom-build", and may delete
images that are still being used (OS#5447). With the other tool, all
images are considered for removal, and the ones that have not been used
the longest time are removed first.
Related: OS#5477, OS#5066, SYS#5827
Change-Id: I1cef0833c096de0fa5acf77156bb5dd362e2ef9c
-rwxr-xr-x | scripts/docker-cleanup.sh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/docker-cleanup.sh b/scripts/docker-cleanup.sh index 34a98b2..49b976b 100755 --- a/scripts/docker-cleanup.sh +++ b/scripts/docker-cleanup.sh @@ -1,10 +1,14 @@ #!/bin/sh -x +# https://osmocom.org/projects/osmocom-servers/wiki/Docker_cache_clean_up +# simple image cleaning code in case docuum isn't running # delete all but the latest images -IMAGES=`docker image ls | grep \^osmocom-build | grep -v latest | awk -F ' ' '{print $1":"$2}'` -for f in $IMAGES; do - docker image rm $f -done +if [ -z "$(docker ps -q -f name=docuum)" ]; then + IMAGES=`docker image ls | grep \^osmocom-build | grep -v latest | awk -F ' ' '{print $1":"$2}'` + for f in $IMAGES; do + docker image rm $f + done +fi # delete all containers where we forgot to use --rm with docker run CONTAINERS="$(docker ps -q -a -f status=exited -f status=created)" |