Skip to content

Commit 3d11dc8

Browse files
Fixing issues and adding mariner
1 parent 60d16d6 commit 3d11dc8

File tree

4 files changed

+134
-41
lines changed

4 files changed

+134
-41
lines changed

src/docker-in-docker/install.sh

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
2121
MICROSOFT_GPG_KEYS_ROLLING_URI="https://packages.microsoft.com/keys/microsoft-rolling.asc"
2222
DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="trixie bookworm buster bullseye bionic focal jammy noble"
2323
DOCKER_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"
2624
DISABLE_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
294284
else
@@ -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
305296
fi
306297

@@ -320,8 +311,8 @@ case ${ADJUSTED_ID} in
320311
;;
321312
esac
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
327318
fi
@@ -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]
368371
name=Microsoft Repository
369372
baseurl=https://packages.microsoft.com/repos/microsoft-cbl-mariner-2.0-prod-base/
370373
enabled=1
371374
gpgcheck=1
372375
gpgkey=file:///etc/pki/rpm-gpg/microsoft.gpg
373376
EOF
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
@@ -388,7 +400,7 @@ else
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
404416
skip_if_unavailable=1
405417
module_hotfixes=1
406418
EOF
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 \
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Simple test script for cbl_mariner scenario (Moby = true)
3+
# Run with: sudo bash script_cbl_mariner.sh
4+
5+
set -e
6+
7+
echo "=== Testing cbl_mariner scenario (Moby) ==="
8+
9+
# Set environment variables for the scenario
10+
export VERSION="latest"
11+
export MOBY="true"
12+
export AZUREDNSAUTODETECTION="false"
13+
14+
# Source OS info
15+
. /etc/os-release
16+
echo "OS: $ID $VERSION_ID"
17+
18+
# Check package manager
19+
if type tdnf > /dev/null 2>&1; then
20+
echo "Using tdnf"
21+
else
22+
echo "ERROR: tdnf not found"
23+
exit 1
24+
fi
25+
26+
# Validate
27+
if command -v docker > /dev/null 2>&1; then
28+
docker --version
29+
echo "SUCCESS: Docker installed"
30+
else
31+
echo "ERROR: Docker not installed"
32+
exit 1
33+
fi
34+
35+
echo "=== cbl_mariner test passed ==="
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# test script for cbl_mariner_docker_ce scenario (Moby = false)
3+
4+
set -e
5+
6+
echo "=== Testing cbl_mariner_docker_ce scenario (Docker CE) ==="
7+
8+
# Set environment variables for the scenario
9+
export VERSION="latest"
10+
export MOBY="false"
11+
export AZUREDNSAUTODETECTION="false"
12+
13+
# Source OS info
14+
. /etc/os-release
15+
echo "OS: $ID $VERSION_ID"
16+
17+
# Check package manager
18+
if type tdnf > /dev/null 2>&1; then
19+
echo "Using tdnf"
20+
else
21+
echo "ERROR: tdnf not found"
22+
exit 1
23+
fi
24+
25+
# Validate
26+
if command -v docker > /dev/null 2>&1; then
27+
docker --version
28+
echo "SUCCESS: Docker installed"
29+
else
30+
echo "ERROR: Docker not installed"
31+
exit 1
32+
fi
33+
34+
echo "=== cbl_mariner_docker_ce test passed ==="

test/docker-in-docker/scenarios.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,25 @@
197197
"azureDnsAutoDetection": false
198198
}
199199
}
200+
},
201+
"cbl_mariner": {
202+
"image": "mcr.microsoft.com/cbl-mariner/base/core:2.0",
203+
"features": {
204+
"docker-in-docker": {
205+
"version": "latest",
206+
"moby": "true",
207+
"azureDnsAutoDetection": false
208+
}
209+
}
210+
},
211+
"cbl_mariner_docker_ce": {
212+
"image": "mcr.microsoft.com/cbl-mariner/base/core:2.0",
213+
"features": {
214+
"docker-in-docker": {
215+
"version": "latest",
216+
"moby": "false",
217+
"azureDnsAutoDetection": false
218+
}
219+
}
200220
}
201221
}

0 commit comments

Comments
 (0)