diff --git a/.buildkite/hooks/post-checkout b/.buildkite/hooks/post-checkout index b47ad6a50d..db20f41cc6 100644 --- a/.buildkite/hooks/post-checkout +++ b/.buildkite/hooks/post-checkout @@ -1,6 +1,21 @@ CI_BUILD_START=$(date +%s) export CI_BUILD_START +# +# Kill any running docker containers, which are potentially left over from the +# previous CI job +# +( + containers=$(docker ps -q) + if [[ -n $containers ]]; then + echo "Killing stale docker containers" + docker ps + + # shellcheck disable=SC2086 # Don't want to double quote $containers + docker kill $containers + fi +) + # Processes from previously aborted CI jobs seem to loiter, unclear why as one # would expect the buildkite-agent to clean up all child processes of the # aborted CI job.