From 92497cf0958500638ea952f570b8d85579467654 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 8 Sep 2015 11:21:38 -0400 Subject: [PATCH] Do not delete containers with the label dokku.service [ci skip] --- plugins/common/functions | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/common/functions b/plugins/common/functions index c84ff522e..983e763e8 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -323,8 +323,13 @@ release_and_deploy() { docker_cleanup() { # delete all non-running containers + # if a container has the label `dokku.service`, + # 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.service' | sort) -3) &> /dev/null || true + # delete unused images # shellcheck disable=SC2046 docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null &