feat: allow setting DOCKER_BIN path for docker execution

This change allows operators to specify a DOCKER_BIN environment variable. This will specify a binary to run when executing docker, which is useful in cases where the 'docker' command being run must be modified in a way that would otherwise be invasive to Dokku, but minimalistic if done within a wrapper.
This commit is contained in:
Jose Diaz-Gonzalez
2019-05-29 00:08:02 -04:00
parent 0e03c82139
commit 785d9b4937
33 changed files with 155 additions and 106 deletions

View File

@@ -95,7 +95,7 @@ fn-scheduler-docker-local-retire-container() {
declare APP="$1" CID="$2" DEAD_TIME="$3"
local STATE
STATE="$(docker inspect -f "{{ .State.Status }}" "$CID" 2>/dev/null || true)"
STATE="$("$DOCKER_BIN" inspect -f "{{ .State.Status }}" "$CID" 2>/dev/null || true)"
if [[ -z "$STATE" ]]; then
return
fi
@@ -104,7 +104,7 @@ fn-scheduler-docker-local-retire-container() {
[[ $DOKKU_DOCKER_STOP_TIMEOUT ]] && DOCKER_STOP_TIME_ARG="--time=${DOKKU_DOCKER_STOP_TIMEOUT}"
if [[ "$STATE" == "restarting" ]]; then
docker update --restart=no "$CID" >/dev/null 2>&1
"$DOCKER_BIN" update --restart=no "$CID" >/dev/null 2>&1
fi
if [[ "$STATE" != "dead" ]] && [[ "$STATE" != "exited" ]]; then
@@ -112,18 +112,18 @@ fn-scheduler-docker-local-retire-container() {
# to not send SIGKILL as the docs would indicate. If that fails, move
# on to the next.
# shellcheck disable=SC2086
docker stop $DOCKER_STOP_TIME_ARG "$CID" \
|| docker kill "$CID" \
"$DOCKER_BIN" stop $DOCKER_STOP_TIME_ARG "$CID" \
|| "$DOCKER_BIN" kill "$CID" \
|| dokku_log_warn "Unable to kill container ${CID}"
fi
STATE="$(docker inspect -f "{{ .State.Status }}" "$CID" 2>/dev/null || true)"
STATE="$("$DOCKER_BIN" inspect -f "{{ .State.Status }}" "$CID" 2>/dev/null || true)"
if [[ -z "$STATE" ]]; then
return
fi
if [[ "$STATE" != "dead" ]] && [[ "$STATE" != "exited" ]]; then
if ! docker kill "$CID"; then
if ! "$DOCKER_BIN" kill "$CID"; then
dokku_log_warn "Unable to kill container ${CID}"
fi
fi