@@ -21,8 +21,6 @@ MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
2121MICROSOFT_GPG_KEYS_ROLLING_URI=" https://packages.microsoft.com/keys/microsoft-rolling.asc"
2222DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES=" trixie bookworm buster bullseye bionic focal jammy noble"
2323DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES=" trixie bookworm buster bullseye bionic focal hirsute impish jammy noble"
24- # Azure Linux support for Moby packages (using official Microsoft repositories)
25- AZURE_LINUX_MOBY_SUPPORTED=" true"
2624DISABLE_IP6_TABLES=" ${DISABLEIP6TABLES:- false} "
2725
2826# Default: Exit on any failure.
@@ -74,21 +72,13 @@ pkg_mgr_update() {
7472 ;;
7573 rhel)
7674 if [ ${PKG_MGR_CMD} = " microdnf" ]; then
77- if [ " $( ls /var/cache/yum/* 2> /dev/null | wc -l) " = 0 ]; then
78- echo " Running ${PKG_MGR_CMD} makecache ..."
79- ${PKG_MGR_CMD} makecache
80- fi
75+ cache_check_dir=" /var/cache/yum"
8176 else
82- if [ " $( ls /var/cache/${PKG_MGR_CMD} /* 2> /dev/null | wc -l) " = 0 ]; then
83- echo " Running ${PKG_MGR_CMD} check-update ..."
84- set +e
85- ${PKG_MGR_CMD} check-update
86- rc=$?
87- if [ $rc != 0 ] && [ $rc != 100 ]; then
88- exit 1
89- fi
90- set -e
91- fi
77+ cache_check_dir=" /var/cache/${PKG_MGR_CMD} "
78+ fi
79+ if [ " $( ls ${cache_check_dir} /* 2> /dev/null | wc -l) " = 0 ]; then
80+ echo " Running ${PKG_MGR_CMD} makecache ..."
81+ ${PKG_MGR_CMD} makecache
9282 fi
9383 ;;
9484 esac
@@ -237,7 +227,7 @@ if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then
237227 else
238228 architecture=" $( uname -m) "
239229 fi
240- elif [[ " ${ID} " = " rhel" || " ${ID} " = " fedora" || " ${ID} " = " azurelinux" || " ${ID} " = " mariner" || " ${ID_LIKE} " = * " rhel" * || " ${ID_LIKE} " = * " fedora" * || " ${ID_LIKE} " = * " mariner" * ]]; then
230+ elif [[ " ${ID} " = " rhel" || " ${ID} " = " fedora" || " ${ID} " = " azurelinux" || " ${ID} " = " mariner" || " ${ID_LIKE} " = * " rhel" * || " ${ID_LIKE} " = * " fedora" * || " ${ID_LIKE} " = * " azurelinux " * || " ${ID_LIKE} " = * " mariner" * ]]; then
241231 ADJUSTED_ID=" rhel"
242232 # Determine the appropriate package manager for RHEL-based systems
243233 if type tdnf > /dev/null 2>&1 ; then
@@ -283,12 +273,12 @@ if [ "${USE_MOBY}" = "true" ]; then
283273 err " Supported distributions include: ${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES} "
284274 exit 1
285275 fi
286- echo " Distro codename ' ${VERSION_CODENAME} ' matched filter ' ${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES} ' "
276+ echo " (*) ${VERSION_CODENAME} is supported for Moby installation (supported: ${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES} ) - setting up Microsoft repository "
287277 elif [ " ${ADJUSTED_ID} " = " rhel" ]; then
288278 if [ " ${ID} " = " azurelinux" ] || [ " ${ID} " = " mariner" ]; then
289- echo " Azure Linux/Mariner detected - using Microsoft repositories for Moby packages"
279+ echo " (*) Azure Linux ${VERSION_ID} /Mariner ${VERSION_ID} detected - using Microsoft repositories for Moby packages"
290280 else
291- echo " RHEL-based system detected - Moby packages may require additional configuration"
281+ echo " RHEL-based system ( ${ID} ) detected - Moby packages may require additional configuration"
292282 fi
293283 fi
294284else
@@ -298,9 +288,10 @@ else
298288 err " Supported distributions include: ${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES} "
299289 exit 1
300290 fi
301- echo " Distro codename ' ${VERSION_CODENAME} ' matched filter ' ${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES} ' "
291+ echo " (*) ${VERSION_CODENAME} is supported for Docker CE installation (supported: ${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES} ) - setting up Docker repository "
302292 elif [ " ${ADJUSTED_ID} " = " rhel" ]; then
303- echo " RHEL-based system detected - using Docker CE packages"
293+
294+ echo " RHEL-based system (${ID} ) detected - using Docker CE packages"
304295 fi
305296fi
306297
@@ -320,8 +311,8 @@ case ${ADJUSTED_ID} in
320311 ;;
321312esac
322313
323- # Swap to legacy iptables for compatibility
324- if type iptables-legacy > /dev/null 2>&1 ; then
314+ # Swap to legacy iptables for compatibility (Debian only)
315+ if [ " ${ADJUSTED_ID} " = " debian " ] type iptables-legacy > /dev/null 2>&1 ; then
325316 update-alternatives --set iptables /usr/sbin/iptables-legacy
326317 update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
327318fi
@@ -361,16 +352,37 @@ if [ "${USE_MOBY}" = "true" ]; then
361352 exit 1
362353 fi
363354 elif [ " ${ID} " = " mariner" ]; then
364- # CBL-Mariner - use Microsoft repository if available
365- curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /etc/pki/rpm-gpg/microsoft.gpg
366- cat > /etc/yum.repos.d/microsoft.repo << EOF
355+ # CBL-Mariner - check if moby packages are available first
356+ echo " (*) CBL-Mariner detected"
357+ echo " (*) Checking for built-in container packages..."
358+
359+ # Check if moby packages are available in default repos first
360+ if ${PKG_MGR_CMD} list available moby-engine > /dev/null 2>&1 ; then
361+ echo " (*) Using built-in CBL-Mariner Moby packages"
362+ # Use default repositories - no additional repo needed
363+ else
364+ echo " (*) Moby packages not found in default repositories"
365+ echo " (*) Adding Microsoft repository for CBL-Mariner..."
366+
367+ # Add Microsoft repository if packages aren't available locally
368+ curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /etc/pki/rpm-gpg/microsoft.gpg
369+ cat > /etc/yum.repos.d/microsoft.repo << EOF
367370[microsoft]
368371name=Microsoft Repository
369372baseurl=https://packages.microsoft.com/repos/microsoft-cbl-mariner-2.0-prod-base/
370373enabled=1
371374gpgcheck=1
372375gpgkey=file:///etc/pki/rpm-gpg/microsoft.gpg
373376EOF
377+ # Verify packages are available after adding repo
378+ pkg_mgr_update
379+ if ! ${PKG_MGR_CMD} list available moby-engine > /dev/null 2>&1 ; then
380+ echo " (*) Moby packages not found in Microsoft repository either"
381+ err " Moby packages are not available for CBL-Mariner ${VERSION_ID} ."
382+ err " Recommendation: Use '\" moby\" : false' to install Docker CE instead."
383+ exit 1
384+ fi
385+ fi
374386 else
375387 err " Moby packages are not available for ${ID} . Please use 'moby': false option."
376388 exit 1
388400 ;;
389401 rhel)
390402 if [ " ${ID} " = " azurelinux" ] || [ " ${ID} " = " mariner" ]; then
391- echo " (*) Azure Linux detected"
403+ echo " (*) ${ID} detected"
392404 echo " (*) Note: Moby packages work better on Azure Linux. Consider using 'moby': true"
393405 echo " (*) Setting up Docker CE repository..."
394406
@@ -404,20 +416,12 @@ gpgkey=file:///etc/pki/rpm-gpg/docker-ce.gpg
404416skip_if_unavailable=1
405417module_hotfixes=1
406418EOF
407-
408- # Azure Linux specific handling for container runtime dependencies
409- echo " (*) Installing container runtime dependencies..."
410- # Install device-mapper libraries (critical for Docker CE)
419+ # Install device-mapper-libs for Docker CE storage management, but skip on Mariner due to repo sync issues and lack of strict requirement
411420 echo " (*) Installing device-mapper libraries for Docker CE..."
412- ${PKG_MGR_CMD} -y install device-mapper-libs || {
413- echo " (*) Trying alternative device-mapper package names..."
414- ${PKG_MGR_CMD} -y install lvm2-libs || {
415- echo " (*) ERROR: Could not install device-mapper libraries"
416- echo " (*) Docker CE requires libdevmapper.so.1.02 to function"
417- exit 1
418- }
419- }
420-
421+ if [ " ${ID} " != " mariner" ]; then
422+ ${PKG_MGR_CMD} -y install device-mapper-libs 2> /dev/null || echo " (*) Device-mapper install failed, proceeding"
423+ fi
424+
421425 # Install other essential libraries for Docker CE
422426 echo " (*) Installing additional Docker CE dependencies..."
423427 ${PKG_MGR_CMD} -y install \
0 commit comments