@@ -56,10 +56,10 @@ break
5656fi
5757done
5858if [ " ${USERNAME} " = " " ]; then
59- USERNAME=root
59+ USERNAME=root
6060fi
6161elif [ " ${USERNAME} " = " none" ] || ! id -u ${USERNAME} > /dev/null 2>&1 ; then
62- USERNAME=root
62+ USERNAME=root
6363fi
6464
6565apt_get_update ()
@@ -397,7 +397,7 @@ if type docker > /dev/null 2>&1 && type dockerd > /dev/null 2>&1; then
397397
398398
399399 elif [ " ${USE_MOBY} " = " true" ] && { [ " $ID " = " fedora" ] || [ " $ID_LIKE " = " rhel" ]; }; then
400- install_docker_or_moby
400+ install_docker_or_moby
401401
402402 elif [ " ${USE_MOBY} " = " false" ] && { [ " $ID " = " fedora" ] || [ " $ID_LIKE " = " rhel" ]; }; then
403403
@@ -491,97 +491,96 @@ curl -fsSL "https://github.com/docker/compose/releases/download/v${compose_versi
491491
492492# If 'docker-compose' command is to be included
493493if [ " ${DOCKER_DASH_COMPOSE_VERSION} " != " none" ]; then
494- case " ${architecture} " in
495- amd64) target_compose_arch=x86_64 ;;
496- arm64) target_compose_arch=aarch64 ;;
497- * )
498- echo " Docker in docker does not support machine architecture '$architecture '. Please use an x86-64 or ARM64 machine."
499- exit 1
500- esac
501-
502- docker_compose_path=" /usr/local/bin/docker-compose"
503- if [ " ${DOCKER_DASH_COMPOSE_VERSION} " = " v1" ]; then
504- err " The final Compose V1 release, version 1.29.2, was May 10, 2021. These packages haven't received any security updates since then. Use at your own risk."
505- INSTALL_DOCKER_COMPOSE_SWITCH=" false"
506-
507- if [ " ${target_compose_arch} " = " x86_64" ]; then
508- echo " (*) Installing docker compose v1..."
509- curl -fsSL " https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64" -o ${docker_compose_path}
510- chmod +x ${docker_compose_path}
511-
512- # Download the SHA256 checksum
513- DOCKER_COMPOSE_SHA256=" $( curl -sSL " https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64.sha256" | awk ' {print $1}' ) "
514- echo " ${DOCKER_COMPOSE_SHA256} ${docker_compose_path} " > docker-compose.sha256sum
515- sha256sum -c docker-compose.sha256sum --ignore-missing
516- elif [ " ${VERSION_CODENAME} " = " bookworm" ]; then
517- err " Docker compose v1 is unavailable for 'bookworm' on Arm64. Kindly switch to use v2"
518- exit 1
519- else
520- # Use pip to get a version that runs on this architecture
521- check_packages python3-minimal python3-pip libffi-dev python3-venv
522- echo " (*) Installing docker compose v1 via pip..."
523- export PYTHONUSERBASE=/usr/local
524- pip3 install --disable-pip-version-check --no-cache-dir --user " Cython<3.0" pyyaml wheel docker-compose --no-build-isolation
525- fi
526- else
527- compose_version=" ${DOCKER_DASH_COMPOSE_VERSION# v} "
528- docker_compose_url=" https://github.com/docker/compose"
529- find_version_from_git_tags compose_version " $docker_compose_url " " tags/v"
530- echo " (*) Installing docker-compose ${compose_version} ..."
531- curl -fsSL " https://github.com/docker/compose/releases/download/compose_version/docker-compose-linux-${target_compose_arch} " -o ${docker_compose_path} || {
532- echo -e " \n(!) Failed to fetch the latest artifacts for docker-compose v${compose_version} ..."
533- fallback_compose " $docker_compose_url "
534- }
535-
536- chmod +x ${docker_compose_path}
494+ case " ${architecture} " in
495+ amd64) target_compose_arch=x86_64 ;;
496+ arm64) target_compose_arch=aarch64 ;;
497+ * )
498+ echo " Docker in docker does not support machine architecture '$architecture '. Please use an x86-64 or ARM64 machine."
499+ exit 1
500+ esac
501+
502+ docker_compose_path=" /usr/local/bin/docker-compose"
503+ if [ " ${DOCKER_DASH_COMPOSE_VERSION} " = " v1" ]; then
504+ err " The final Compose V1 release, version 1.29.2, was May 10, 2021. These packages haven't received any security updates since then. Use at your own risk."
505+ INSTALL_DOCKER_COMPOSE_SWITCH=" false"
506+
507+ if [ " ${target_compose_arch} " = " x86_64" ]; then
508+ echo " (*) Installing docker compose v1..."
509+ curl -fsSL " https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64" -o ${docker_compose_path}
510+ chmod +x ${docker_compose_path}
511+
512+ # Download the SHA256 checksum
513+ DOCKER_COMPOSE_SHA256=" $( curl -sSL " https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64.sha256" | awk ' {print $1}' ) "
514+ echo " ${DOCKER_COMPOSE_SHA256} ${docker_compose_path} " > docker-compose.sha256sum
515+ sha256sum -c docker-compose.sha256sum --ignore-missing
516+ elif [ " ${VERSION_CODENAME} " = " bookworm" ]; then
517+ err " Docker compose v1 is unavailable for 'bookworm' on Arm64. Kindly switch to use v2"
518+ exit 1
519+ else
520+ # Use pip to get a version that runs on this architecture
521+ check_packages python3-minimal python3-pip libffi-dev python3-venv
522+ echo " (*) Installing docker compose v1 via pip..."
523+ export PYTHONUSERBASE=/usr/local
524+ pip3 install --disable-pip-version-check --no-cache-dir --user " Cython<3.0" pyyaml wheel docker-compose --no-build-isolation
525+ fi
526+ else
527+ compose_version=" ${DOCKER_DASH_COMPOSE_VERSION# v} "
528+ docker_compose_url=" https://github.com/docker/compose"
529+ find_version_from_git_tags compose_version " $docker_compose_url " " tags/v"
530+ echo " (*) Installing docker-compose ${compose_version} ..."
531+ curl -fsSL " https://github.com/docker/compose/releases/download/compose_version/docker-compose-linux-${target_compose_arch} " -o ${docker_compose_path} || {
532+ echo -e " \n(!) Failed to fetch the latest artifacts for docker-compose v${compose_version} ..."
533+ fallback_compose " $docker_compose_url "
534+ }
535+ chmod +x ${docker_compose_path}
537536
538- # Download the SHA256 checksum
539- DOCKER_COMPOSE_SHA256=" $( curl -sSL " https://github.com/docker/compose/releases/download/v${compose_version} /docker-compose-linux-${target_compose_arch} .sha256" | awk ' {print $1}' ) "
540- echo " ${DOCKER_COMPOSE_SHA256} ${docker_compose_path} " > docker-compose.sha256sum
541- sha256sum -c docker-compose.sha256sum --ignore-missing
537+ # Download the SHA256 checksum
538+ DOCKER_COMPOSE_SHA256=" $( curl -sSL " https://github.com/docker/compose/releases/download/v${compose_version} /docker-compose-linux-${target_compose_arch} .sha256" | awk ' {print $1}' ) "
539+ echo " ${DOCKER_COMPOSE_SHA256} ${docker_compose_path} " > docker-compose.sha256sum
540+ sha256sum -c docker-compose.sha256sum --ignore-missing
542541
543- mkdir -p ${cli_plugins_dir}
544- cp ${docker_compose_path} ${cli_plugins_dir}
545- fi
542+ mkdir -p ${cli_plugins_dir}
543+ cp ${docker_compose_path} ${cli_plugins_dir}
544+ fi
546545fi
547546
548547# fallback method for compose-switch
549548fallback_compose-switch () {
550- local url=$1
551- local repo_url=$( get_github_api_repo_url " $url " )
552- echo -e " \n(!) Failed to fetch the latest artifacts for compose-switch v${compose_switch_version} ..."
553- get_previous_version " $url " " $repo_url " compose_switch_version
554- echo -e " \nAttempting to install v${compose_switch_version} "
555- curl -fsSL " https://github.com/docker/compose-switch/releases/download/v${compose_switch_version} /docker-compose-linux-${architecture} " -o /usr/local/bin/compose-switch
549+ local url=$1
550+ local repo_url=$( get_github_api_repo_url " $url " )
551+ echo -e " \n(!) Failed to fetch the latest artifacts for compose-switch v${compose_switch_version} ..."
552+ get_previous_version " $url " " $repo_url " compose_switch_version
553+ echo -e " \nAttempting to install v${compose_switch_version} "
554+ curl -fsSL " https://github.com/docker/compose-switch/releases/download/v${compose_switch_version} /docker-compose-linux-${architecture} " -o /usr/local/bin/compose-switch
556555}
557556
558557# Install docker-compose switch if not already installed - https://github.com/docker/compose-switch#manual-installation
559558if [ " ${INSTALL_DOCKER_COMPOSE_SWITCH} " = " true" ] && ! type compose-switch > /dev/null 2>&1 ; then
560- if type docker-compose > /dev/null 2>&1 ; then
561- echo " (*) Installing compose-switch..."
562- current_compose_path=" $( which docker-compose) "
563- target_compose_path=" $( dirname " ${current_compose_path} " ) /docker-compose-v1"
564- compose_switch_version=" latest"
565- compose_switch_url=" https://github.com/docker/compose-switch"
566- find_version_from_git_tags compose_switch_version " $compose_switch_url "
567- curl -fsSL " https://github.com/docker/compose-switch/releases/download/v${compose_switch_version} /docker-compose-linux-${architecture} " -o /usr/local/bin/compose-switch || fallback_compose-switch " $compose_switch_url "
568- chmod +x /usr/local/bin/compose-switch
569- # TODO: Verify checksum once available: https://github.com/docker/compose-switch/issues/11
570- # Setup v1 CLI as alternative in addition to compose-switch (which maps to v2)
571- mv " ${current_compose_path} " " ${target_compose_path} "
572- update-alternatives --install ${docker_compose_path} docker-compose /usr/local/bin/compose-switch 99
573- update-alternatives --install ${docker_compose_path} docker-compose " ${target_compose_path} " 1
574- else
575- err " Skipping installation of compose-switch as docker compose is unavailable..."
576- fi
559+ if type docker-compose > /dev/null 2>&1 ; then
560+ echo " (*) Installing compose-switch..."
561+ current_compose_path=" $( which docker-compose) "
562+ target_compose_path=" $( dirname " ${current_compose_path} " ) /docker-compose-v1"
563+ compose_switch_version=" latest"
564+ compose_switch_url=" https://github.com/docker/compose-switch"
565+ find_version_from_git_tags compose_switch_version " $compose_switch_url "
566+ curl -fsSL " https://github.com/docker/compose-switch/releases/download/v${compose_switch_version} /docker-compose-linux-${architecture} " -o /usr/local/bin/compose-switch || fallback_compose-switch " $compose_switch_url "
567+ chmod +x /usr/local/bin/compose-switch
568+ # TODO: Verify checksum once available: https://github.com/docker/compose-switch/issues/11
569+ # Setup v1 CLI as alternative in addition to compose-switch (which maps to v2)
570+ mv " ${current_compose_path} " " ${target_compose_path} "
571+ update-alternatives --install ${docker_compose_path} docker-compose /usr/local/bin/compose-switch 99
572+ update-alternatives --install ${docker_compose_path} docker-compose " ${target_compose_path} " 1
573+ else
574+ err " Skipping installation of compose-switch as docker compose is unavailable..."
575+ fi
577576fi
578577
579578# If init file already exists, exit
580579if [ -f " /usr/local/share/docker-init.sh" ]; then
581- echo " /usr/local/share/docker-init.sh already exists, so exiting."
582- # Clean up
583- rm -rf /var/lib/apt/lists/*
584- exit 0
580+ echo " /usr/local/share/docker-init.sh already exists, so exiting."
581+ # Clean up
582+ rm -rf /var/lib/apt/lists/*
583+ exit 0
585584fi
586585echo " docker-init doesn't exist, adding..."
587586
@@ -593,52 +592,52 @@ usermod -aG docker ${USERNAME}
593592
594593# fallback for docker/buildx
595594fallback_buildx () {
596- local url=$1
597- local repo_url=$( get_github_api_repo_url " $url " )
598- echo -e " \nFailed to fetch the latest artifacts for docker buildx v${buildx_version} ..."
599- get_previous_version " $url " " $repo_url " buildx_version
600- buildx_file_name=" buildx-v${buildx_version} .linux-amd64"
601- echo -e " \nAttempting to install v${buildx_version} "
602- wget https://github.com/docker/buildx/releases/download/v${buildx_version} /${buildx_file_name}
595+ local url=$1
596+ local repo_url=$( get_github_api_repo_url " $url " )
597+ echo -e " \nFailed to fetch the latest artifacts for docker buildx v${buildx_version} ..."
598+ get_previous_version " $url " " $repo_url " buildx_version
599+ buildx_file_name=" buildx-v${buildx_version} .linux-amd64"
600+ echo -e " \nAttempting to install v${buildx_version} "
601+ wget https://github.com/docker/buildx/releases/download/v${buildx_version} /${buildx_file_name}
603602}
604603
605604if [ " ${INSTALL_DOCKER_BUILDX} " = " true" ]; then
606- buildx_version=" latest"
607- docker_buildx_url=" https://github.com/docker/buildx"
608- find_version_from_git_tags buildx_version " $docker_buildx_url " " refs/tags/v"
609- echo ' (*) Installing buildx ${buildx_version}...'
610- buildx_file_name=" buildx-v${buildx_version} .linux-${architecture} "
605+ buildx_version=" latest"
606+ docker_buildx_url=" https://github.com/docker/buildx"
607+ find_version_from_git_tags buildx_version " $docker_buildx_url " " refs/tags/v"
608+ echo ' (*) Installing buildx ${buildx_version}...'
609+ buildx_file_name=" buildx-v${buildx_version} .linux-${architecture} "
611610
612- cd /tmp
613- wget https://github.com/docker/buildx/releases/download/v${buildx_version} /${buildx_file_name} || fallback_buildx " $docker_buildx_url "
611+ cd /tmp
612+ wget https://github.com/docker/buildx/releases/download/v${buildx_version} /${buildx_file_name} || fallback_buildx " $docker_buildx_url "
614613
615- docker_home=" /usr/libexec/docker"
616- cli_plugins_dir=" ${docker_home} /cli-plugins"
614+ docker_home=" /usr/libexec/docker"
615+ cli_plugins_dir=" ${docker_home} /cli-plugins"
617616
618- mkdir -p " ${cli_plugins_dir} "
619- mv " ${buildx_file_name} " " ${cli_plugins_dir} /docker-buildx"
620- chmod +x " ${cli_plugins_dir} /docker-buildx"
617+ mkdir -p " ${cli_plugins_dir} "
618+ mv " ${buildx_file_name} " " ${cli_plugins_dir} /docker-buildx"
619+ chmod +x " ${cli_plugins_dir} /docker-buildx"
621620
622- chown -R " ${USERNAME} :docker" " ${docker_home} "
623- chmod -R g+r+w " ${docker_home} "
624- find " ${docker_home} " -type d -print0 | xargs -n 1 -0 chmod g+s
621+ chown -R " ${USERNAME} :docker" " ${docker_home} "
622+ chmod -R g+r+w " ${docker_home} "
623+ find " ${docker_home} " -type d -print0 | xargs -n 1 -0 chmod g+s
625624fi
626625
627626DOCKER_DEFAULT_IP6_TABLES=" "
628627if [ " $DISABLE_IP6_TABLES " == true ]; then
629- requested_version=" "
630- # checking whether the version requested either is in semver format or just a number denoting the major version
631- # and, extracting the major version number out of the two scenarios
632- semver_regex=' ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$'
633- if echo " $DOCKER_VERSION " | grep -Eq $semver_regex ; then
634- requested_version=$( echo $DOCKER_VERSION | cut -d. -f1)
635- elif echo " $DOCKER_VERSION " | grep -Eq " ^[1-9][0-9]*$" ; then
636- requested_version=$DOCKER_VERSION
637- fi
638- if [ " $DOCKER_VERSION " = " latest" ] || [[ -n " $requested_version " && " $requested_version " -ge 27 ]]; then
639- DOCKER_DEFAULT_IP6_TABLES=" --ip6tables=false"
640- echo " ! As requested, passing ${DOCKER_DEFAULT_IP6_TABLES} "
641- fi
628+ requested_version=" "
629+ # checking whether the version requested either is in semver format or just a number denoting the major version
630+ # and, extracting the major version number out of the two scenarios
631+ semver_regex=' ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$'
632+ if echo " $DOCKER_VERSION " | grep -Eq $semver_regex ; then
633+ requested_version=$( echo $DOCKER_VERSION | cut -d. -f1)
634+ elif echo " $DOCKER_VERSION " | grep -Eq " ^[1-9][0-9]*$" ; then
635+ requested_version=$DOCKER_VERSION
636+ fi
637+ if [ " $DOCKER_VERSION " = " latest" ] || [[ -n " $requested_version " && " $requested_version " -ge 27 ]]; then
638+ DOCKER_DEFAULT_IP6_TABLES=" --ip6tables=false"
639+ echo " ! As requested, passing ${DOCKER_DEFAULT_IP6_TABLES} "
640+ fi
642641fi
643642
644643tee /usr/local/share/docker-init.sh > /dev/null \
@@ -742,7 +741,7 @@ INNEREOF
742741
743742
744743sudo_if() {
745- COMMAND="$*"
744+ COMMAND="$*"
746745
747746 if [ "$(id -u)" -ne 0 ]; then
748747 sudo $COMMAND
0 commit comments