Skip to content

Commit

Permalink
Fix check docker helper to exit properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Heckel committed Sep 2, 2021
1 parent ab17f83 commit 715188b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions config/script.d/helpers/docker-run
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,26 @@ if [ -z "${mem}" ]; then
mem=128
else
mem="$((mem / 1024 / divisor))"
if [ "${mem}" -lt "1280000000" ]; then
if [ "${mem}" -lt "128" ]; then
mem=128
fi
fi

# Horrible hack to kill container when the disk grows into GB range,
# since --storage-opt is not available for ext4
check_file=/tmp/$name.check_docker
touch "${check_file}"

cleanup() { rm -f "${check_file}"; }
trap cleanup EXIT

check_docker() {
trap cleanup EXIT
while :; do
toobig=$(docker ps -f "name=$name" --format '{{.Names}} {{.Size}}' | awk '$2 ~ /^[0-9]+(\.[0-9]+)?G/ { print }')
if [ ! -f "${check_file}" ]; then
exit
fi
toobig=$(docker ps -f "name=$name" --format '{{.Size}}' | awk '$1 ~ /^[0-9]+(\.[0-9]+)?G/ { print }')
if [ -n "${toobig}" ]; then
echo; echo "Oh no, you've used too much disk space. Please try to behave next time. Exiting."
docker kill "$name" >/dev/null
Expand Down

0 comments on commit 715188b

Please sign in to comment.