only remove containers with dokku label. closes #1220
This commit is contained in:
@@ -414,11 +414,11 @@ docker_cleanup() {
|
|||||||
declare desc="cleans up all exited/dead containers and removes all dangling images"
|
declare desc="cleans up all exited/dead containers and removes all dangling images"
|
||||||
# delete all non-running containers
|
# delete all non-running containers
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null || true
|
docker rm $(docker ps -a -f "status=exited" -f "label=$DOKKU_CONTAINER_LABEL" -q) &> /dev/null || true
|
||||||
|
|
||||||
# delete all dead containers
|
# delete all dead containers
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
docker rm $(docker ps -a -f 'status=dead' -q) &> /dev/null || true
|
docker rm $(docker ps -a -f "status=dead" -f "label=$DOKKU_CONTAINER_LABEL" -q) &> /dev/null || true
|
||||||
|
|
||||||
# delete unused images
|
# delete unused images
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
|
|||||||
@@ -40,16 +40,25 @@ build_nginx_config() {
|
|||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
|
RANDOM_RUN_CID="$(docker run -d gliderlabs/herokuish bash)"
|
||||||
|
docker ps -a
|
||||||
run dokku cleanup
|
run dokku cleanup
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_success
|
assert_success
|
||||||
sleep 5 # wait for dokku cleanup to happen in the background
|
sleep 5 # wait for dokku cleanup to happen in the background
|
||||||
|
|
||||||
|
docker ps -a
|
||||||
run bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
run bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_failure
|
assert_failure
|
||||||
|
|
||||||
|
run bash -c "docker inspect $RANDOM_RUN_CID"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" {
|
@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" {
|
||||||
|
|||||||
Reference in New Issue
Block a user