diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index 77b229281..3d1a93fd8 100644 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -71,11 +71,12 @@ if test "${BUILDKITE_COMMAND_EXIT_STATUS}" -ne "0"; then fi # Kill any running containers (clear state), except for "bootstrap". -for container in $(docker ps -q); do - maybe_kill="$(docker inspect -f '{{if ne "/bootstrap" .Name}}true{{ end }}' "${container}")" - if test -n "${maybe_kill}"; then - docker container kill "${container}" +for id_and_name in $(docker ps --format='{{.ID}} {{.Names}}'); do + if [[ "$(echo "$id_and_name" | cut -d' ' -f2-)" == 'bootstrap' ]]; then + continue fi + timeout --kill-after=10s --preserve-status 8s \ + docker container kill "$(echo "$id_and_name" | cut -d' ' -f1)" done set -euo pipefail