From 7eddf071559be8f754feaa207f8f93440b05243f Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Thu, 19 Mar 2020 16:15:54 +1100 Subject: [PATCH] [Buildkite] Clean Docker environment on exit (#734) --- .buildkite/hooks/post-command | 2 +- .buildkite/hooks/pre-exit | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 .buildkite/hooks/pre-exit diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index d485aaef..b9a30d82 100755 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -5,7 +5,7 @@ set +u if [[ $BUILDKITE_LABEL =~ ":selenium:" ]] || [[ $BUILDKITE_LABEL =~ ":docker: Build Image" ]]; then CONTAINERS=$(docker ps -a -q) if [[ ${CONTAINERS} != "" ]]; then - echo "--- :docker: Clean environment" + echo "--- :docker: Remove lingering containers" docker rm -f ${CONTAINERS} fi fi diff --git a/.buildkite/hooks/pre-exit b/.buildkite/hooks/pre-exit new file mode 100755 index 00000000..6a1767f9 --- /dev/null +++ b/.buildkite/hooks/pre-exit @@ -0,0 +1,6 @@ +#!/bin/bash + +set +u + +echo "--- :docker: Clean environment" +docker system prune -af --volumes \ No newline at end of file