From 697501259a68608493ec17bc5cc2ab749f3762ef Mon Sep 17 00:00:00 2001 From: Francisco Sales Date: Wed, 17 Jan 2018 13:07:23 +0000 Subject: [PATCH 1/2] Removing unused docker volumes this only works for docker v1.9+ --- tunesys/tuner/DOCKER | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tunesys/tuner/DOCKER b/tunesys/tuner/DOCKER index 8f2fa78..3b37c69 100755 --- a/tunesys/tuner/DOCKER +++ b/tunesys/tuner/DOCKER @@ -15,6 +15,13 @@ while true; do docker images -q | xargs docker rmi fi + + if [ $docker_remove_volumes == "1" ]; then + + echo "Removing unused docker volumes" + docker volume ls -qf dangling=true | xargs -r docker volume rm + + fi # Sleep sleep $docker_loop_interval From fbc2a58a506be9c2246db99cdbf174ff1dcc62e3 Mon Sep 17 00:00:00 2001 From: Francisco Sales Date: Wed, 17 Jan 2018 13:22:17 +0000 Subject: [PATCH 2/2] add to defalt envs and docs --- Dockerfile | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 341c2b4..d6be4bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ ENV TUNE_TCP=1 \ ENV TUNE_DOCKER=1 \ docker_remove_containers=1 \ docker_remove_images=1 \ + docker_remove_volumes=1 \ docker_loop_interval=21600 WORKDIR /tunesys diff --git a/README.md b/README.md index 474d300..b49ef15 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ It has built-in configurable tuners that handles minor settings, such as: * Docker - Removes all images that are not being used. Option enable by default `docker_remove_images=1` in Dockerfile - Removes all stoped containers. Option enable by default `docker_remove_containers=1` in Dockerfile. + - Removes all dangling volume. Option enable by default `docker_remove_volumes=1` in Dockerfile. ## Deploying