这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dokku
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ case "$1" in

cleanup)
# delete all non-running container
docker rm "$(docker ps -a -f 'status=exited' -q)" &> /dev/null &
# shellcheck disable=SC2046
docker rm $(docker ps -a -f 'status=exited' -q) &> /dev/null &
# delete unused images
docker rmi "$(docker images -f 'dangling=true' -q)" &> /dev/null &
# shellcheck disable=SC2046
docker rmi $(docker images -f 'dangling=true' -q) &> /dev/null &
;;

plugins)
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/cleanup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ teardown() {
}

@test "remove exited containers" {
run dokku run $TEST_APP hostname
# make sure we have many exited containers of the same 'type'
run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done"
echo "output: "$output
echo "status: "$status
container="$output"
assert_success
run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false | grep -q $container"
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_success
run dokku cleanup
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false | grep -q $container"
sleep 5 # wait for dokku cleanup to happen in the background
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_failure
Expand Down