Skip to content

Commit

Permalink
Update the docker and docker-compose version check
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-antonyuk committed Feb 21, 2025
1 parent 3b1cefc commit 5c5606e
Showing 1 changed file with 10 additions and 39 deletions.
49 changes: 10 additions & 39 deletions install/OneClickInstall/install-Docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ install_package () {
}

install_docker_compose () {
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
curl -sL "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
}

Expand Down Expand Up @@ -850,42 +850,6 @@ check_ports () {
fi
}

check_docker_version () {
CUR_FULL_VERSION=$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1)
CUR_VERSION=$(echo $CUR_FULL_VERSION | cut -d '-' -f1)
CUR_EDITION=$(echo $CUR_FULL_VERSION | cut -d '-' -f2)

if [ "${CUR_EDITION}" == "ce" ] || [ "${CUR_EDITION}" == "ee" ]; then
return 0
fi

if [ "${CUR_VERSION}" != "${CUR_EDITION}" ]; then
echo "Unspecific docker version"
exit 1
fi

MIN_NUM_ARR=(1 10 0)
CUR_NUM_ARR=();

CUR_STR_ARR=$(echo $CUR_VERSION | grep -Po "[0-9]+\.[0-9]+\.[0-9]+" | tr "." " ")

for CUR_STR_ITEM in $CUR_STR_ARR; do
CUR_NUM_ARR+=("$CUR_STR_ITEM")
done

INDEX=0

while [[ $INDEX -lt 3 ]]; do
if [ ${CUR_NUM_ARR[INDEX]} -lt ${MIN_NUM_ARR[INDEX]} ]; then
echo "The outdated Docker version has been found. Please update to the latest version."
exit 1
elif [ ${CUR_NUM_ARR[INDEX]} -gt ${MIN_NUM_ARR[INDEX]} ]; then
return 0
fi
(( INDEX++ ))
done
}

install_docker () {

if [ "${DIST}" == "Ubuntu" ] || [ "${DIST}" == "Debian" ] || [[ "${DIST}" == CentOS* ]] || [ "${DIST}" == "Fedora" ]; then
Expand Down Expand Up @@ -1424,11 +1388,17 @@ dependency_installation() {
install_package jq
fi

is_command_exists docker && { check_docker_version; systemctl start docker; } || { [ "${OFFLINE_INSTALLATION}" = "false" ] && install_docker || { echo "docker not installed"; exit 1; }; }
if ! is_command_exists docker; then
[ "${OFFLINE_INSTALLATION}" = "false" ] && install_docker || { echo "docker not installed"; exit 1; }
elif [ "$(docker --version | awk -F'[ ,.]' '{print $3}')" -lt "18" ]; then
[ "$OFFLINE_INSTALLATION" = "false" ] && install_docker || { echo "docker version is outdated"; exit 1; }
else
systemctl start docker
fi

if ! is_command_exists docker-compose; then
[ "${OFFLINE_INSTALLATION}" = "false" ] && install_docker_compose || { echo "docker-compose not installed"; exit 1; }
elif [ "$(docker-compose --version | grep -oP '(?<=v)\d+\.\d+'| sed 's/\.//')" -lt "21" ]; then
elif [ $(docker-compose -v | awk '{sub(/^v/,"",$NF);split($NF,a,".");printf "%d%03d%03d",a[1],a[2],a[3]}') -lt 2018000 ]; then
[ "$OFFLINE_INSTALLATION" = "false" ] && install_docker_compose || { echo "docker-compose version is outdated"; exit 1; }
fi
}
Expand Down Expand Up @@ -1458,6 +1428,7 @@ check_docker_image () {

if [ "$INSTALL_PRODUCT" == "true" ]; then
offline_check_docker_image ${BASE_DIR}/migration-runner.yml
offline_check_docker_image ${BASE_DIR}/identity.yml
offline_check_docker_image ${BASE_DIR}/${PRODUCT}.yml
offline_check_docker_image ${BASE_DIR}/notify.yml
offline_check_docker_image ${BASE_DIR}/healthchecks.yml
Expand Down

0 comments on commit 5c5606e

Please sign in to comment.