diff --git a/plugins/common/functions b/plugins/common/functions index 53d1dd457..facc6bc17 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -222,6 +222,11 @@ is_image_herokuish_based() { docker run "$DOKKU_GLOBAL_RUN_ARGS" --entrypoint="/bin/sh" $DOCKER_ARGS "$@" -c "test -f /exec" &> /dev/null } +get_docker_version() { + CLIENT_VERSION_STRING="$(docker version -f="{{ .Client.Version }}")" + echo "$CLIENT_VERSION_STRING" +} + is_number() { declare desc="returns 0 if input is a number" local NUMBER=$1; local NUM_RE='^[0-9]+$' diff --git a/plugins/tags/functions b/plugins/tags/functions index cd244c105..76313462e 100755 --- a/plugins/tags/functions +++ b/plugins/tags/functions @@ -2,7 +2,23 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +is_tag_force_available() { + CLIENT_VERSION_STRING="$(get_docker_version)" + MAJOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[1]}') + MINOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[2]}') + PATCH_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[3]}') + + # docker tag -f was dropped in 1.12.0 + if [[ "$MAJOR_VERSION" -ge 1 ]] && [[ "$MINOR_VERSION" -ge 12 ]]; then + return 1 + else + return 0 + fi +} + tag_image() { declare desc="convenience method for docker tag interface" - docker tag -f "$1" "$2" + [[ $(is_tag_force_available) ]] && TAG_OPTS="-f" + # shellcheck disable=SC2086 + docker tag $TAG_OPTS "$1" "$2" }