From 342e9aa95ba3e8f13b89f9202cda7a493078c40d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 6 Sep 2015 19:21:12 -0400 Subject: [PATCH 1/3] Move dokku cleanup into docker_cleanup function This should slightly reduce DOKKU_TRACE output. --- dokku | 9 ++------- plugins/common/functions | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dokku b/dokku index 8142338f1..1aa73fd23 100755 --- a/dokku +++ b/dokku @@ -53,7 +53,7 @@ case "$1" in receive) APP="$2"; IMAGE=$(get_app_image_name $APP); IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4" dokku_log_info1 "Cleaning up..." - dokku cleanup + docker_cleanup dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE..." dokku build "$APP" "$IMAGE_SOURCE_TYPE" "$TMP_WORK_DIR" release_and_deploy "$APP" @@ -192,12 +192,7 @@ case "$1" in ;; cleanup) - # delete all non-running container - # shellcheck disable=SC2046 - docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null || true - # delete unused images - # shellcheck disable=SC2046 - docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null & + docker_cleanup ;; plugins) diff --git a/plugins/common/functions b/plugins/common/functions index 44cab7fc8..2d10c708d 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -320,3 +320,12 @@ release_and_deploy() { echo fi } + +docker_cleanup() { + # delete all non-running container + # shellcheck disable=SC2046 + docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null || true + # delete unused images + # shellcheck disable=SC2046 + docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null & +} From d0c0ffc19c25f8003e05ba85a5d43e33643fb731 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 6 Sep 2015 19:23:15 -0400 Subject: [PATCH 2/3] Do not remove any containers that have the label `dokku`. Closes #1220 This can be used to mark data containers as non-removable by the cleanup function --- plugins/common/functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index 2d10c708d..12c6dc05b 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -322,9 +322,13 @@ release_and_deploy() { } docker_cleanup() { - # delete all non-running container + # delete all non-running containers + # if a container has the label `dokku`, + # then that container is not deleted. + # This can be used to mark data containers + # as non-removable by the cleanup function # shellcheck disable=SC2046 - docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null || true + docker rm $(comm <(docker ps -aq -f 'status=exited' | sort) <(docker ps -aq -f 'status=exited' -f 'label=dokku' | sort) -3) &> /dev/null || true # delete unused images # shellcheck disable=SC2046 docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null & From ba82b544f0e4e296fc5b9ac68bc820b5b9843fcf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 6 Sep 2015 19:40:44 -0400 Subject: [PATCH 3/3] Proper spacing in dokku_log_warn --- plugins/common/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/functions b/plugins/common/functions index 12c6dc05b..282c5715c 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -82,7 +82,7 @@ dokku_log_verbose() { } dokku_log_warn() { - echo " ! $@" + echo " ! $@" } dokku_log_fail() {