Skip to content

Commit 6c2ca34

Browse files
correcting the indentation for better readability
1 parent 98a73fe commit 6c2ca34

File tree

1 file changed

+86
-89
lines changed

1 file changed

+86
-89
lines changed

src/docker-in-docker/install.sh

Lines changed: 86 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -242,103 +242,103 @@ fi
242242

243243
# Check if distro is supported
244244
if [ "${USE_MOBY}" = "true" ]; then
245-
if [[ "${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES}" != *"${VERSION_CODENAME}"* ]]; then
246-
err "Unsupported distribution version '${VERSION_CODENAME}'. To resolve, either: (1) set feature option '\"moby\": false' , or (2) choose a compatible OS distribution"
247-
err "Support distributions include: ${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES}"
248-
exit 1
249-
fi
250-
echo "Distro codename '${VERSION_CODENAME}' matched filter '${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES}'"
245+
if [[ "${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES}" != *"${VERSION_CODENAME}"* ]]; then
246+
err "Unsupported distribution version '${VERSION_CODENAME}'. To resolve, either: (1) set feature option '\"moby\": false' , or (2) choose a compatible OS distribution"
247+
err "Support distributions include: ${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES}"
248+
exit 1
249+
fi
250+
echo "Distro codename '${VERSION_CODENAME}' matched filter '${DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES}'"
251251
else
252252
if [[ "${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES}" != *"${VERSION_CODENAME}"* ]]; then
253-
err "Unsupported distribution version '${VERSION_CODENAME}'. To resolve, please choose a compatible OS distribution"
254-
err "Support distributions include: '${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES}'"
255-
exit 1
253+
err "Unsupported distribution version '${VERSION_CODENAME}'. To resolve, please choose a compatible OS distribution"
254+
err "Support distributions include: '${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES}'"
255+
exit 1
256256
fi
257257
echo "Distro codename '${VERSION_CODENAME}' matched filter '${DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES}'"
258258
fi
259259

260260
# Install dependencies
261261
check_packages apt-transport-https curl ca-certificates pigz iptables gnupg2 dirmngr wget jq
262262
if ! type git > /dev/null 2>&1; then
263-
check_packages git
263+
check_packages git
264264
fi
265265
# Swap to legacy iptables for compatibility
266266
if type iptables-legacy > /dev/null 2>&1; then
267-
update-alternatives --set iptables /usr/sbin/iptables-legacy
268-
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
267+
update-alternatives --set iptables /usr/sbin/iptables-legacy
268+
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
269269
fi
270270
# https://github.com/devcontainers/features/issues/1235
271271
if uname -r | grep -q '\.fc'; then
272-
sudo update-alternatives --set iptables /usr/sbin/iptables-nft
272+
sudo update-alternatives --set iptables /usr/sbin/iptables-nft
273273
fi
274274

275275
# Set up the necessary apt repos (either Microsoft's or Docker's)
276276
if [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then
277-
if [ "${USE_MOBY}" = "true" ]; then
277+
if [ "${USE_MOBY}" = "true" ]; then
278278

279-
# Name of open source engine/cli
280-
engine_package_name="moby-engine"
281-
cli_package_name="moby-cli"
279+
# Name of open source engine/cli
280+
engine_package_name="moby-engine"
281+
cli_package_name="moby-cli"
282282

283-
# Import key safely and import Microsoft apt repo
284-
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
285-
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
286-
else
287-
# Name of licensed engine/cli
288-
engine_package_name="docker-ce"
289-
cli_package_name="docker-ce-cli"
283+
# Import key safely and import Microsoft apt repo
284+
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
285+
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
286+
else
287+
# Name of licensed engine/cli
288+
engine_package_name="docker-ce"
289+
cli_package_name="docker-ce-cli"
290290

291-
# Import key safely and import Docker apt repo
292-
curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg
293-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list
294-
fi
291+
# Import key safely and import Docker apt repo
292+
curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg
293+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list
294+
fi
295295

296296
# Refresh apt lists
297297
apt-get update
298298
fi
299299
# Soft version matching
300300
if [ "${DOCKER_VERSION}" = "latest" ] || [ "${DOCKER_VERSION}" = "lts" ] || [ "${DOCKER_VERSION}" = "stable" ]; then
301-
# Empty, meaning grab whatever "latest" is in apt repo
302-
engine_version_suffix=""
303-
cli_version_suffix=""
304-
else
305-
# Fetch a valid version from the apt-cache (eg: the Microsoft repo appends +azure, breakfix, etc...)
306-
docker_version_dot_escaped="${DOCKER_VERSION//./\\.}"
307-
docker_version_dot_plus_escaped="${docker_version_dot_escaped//+/\\+}"
308-
# Regex needs to handle debian package version number format: https://www.systutorials.com/docs/linux/man/5-deb-version/
309-
docker_version_regex="^(.+:)?${docker_version_dot_plus_escaped}([\\.\\+ ~:-]|$)"
310-
set +e # Don't exit if finding version fails - will handle gracefully
311-
cli_version_suffix="=$(apt-cache madison ${cli_package_name} | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${docker_version_regex}")"
312-
engine_version_suffix="=$(apt-cache madison ${engine_package_name} | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${docker_version_regex}")"
313-
set -e
314-
if [ -z "${engine_version_suffix}" ] || [ "${engine_version_suffix}" = "=" ] || [ -z "${cli_version_suffix}" ] || [ "${cli_version_suffix}" = "=" ] ; then
315-
err "No full or partial Docker / Moby version match found for \"${DOCKER_VERSION}\" on OS ${ID} ${VERSION_CODENAME} (${architecture}). Available versions:"
316-
apt-cache madison ${cli_package_name} | awk -F"|" '{print $2}' | grep -oP '^(.+:)?\K.+'
317-
exit 1
318-
fi
319-
echo "engine_version_suffix ${engine_version_suffix}"
320-
echo "cli_version_suffix ${cli_version_suffix}"
301+
# Empty, meaning grab whatever "latest" is in apt repo
302+
engine_version_suffix=""
303+
cli_version_suffix=""
304+
else
305+
# Fetch a valid version from the apt-cache (eg: the Microsoft repo appends +azure, breakfix, etc...)
306+
docker_version_dot_escaped="${DOCKER_VERSION//./\\.}"
307+
docker_version_dot_plus_escaped="${docker_version_dot_escaped//+/\\+}"
308+
# Regex needs to handle debian package version number format: https://www.systutorials.com/docs/linux/man/5-deb-version/
309+
docker_version_regex="^(.+:)?${docker_version_dot_plus_escaped}([\\.\\+ ~:-]|$)"
310+
set +e # Don't exit if finding version fails - will handle gracefully
311+
cli_version_suffix="=$(apt-cache madison ${cli_package_name} | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${docker_version_regex}")"
312+
engine_version_suffix="=$(apt-cache madison ${engine_package_name} | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${docker_version_regex}")"
313+
set -e
314+
if [ -z "${engine_version_suffix}" ] || [ "${engine_version_suffix}" = "=" ] || [ -z "${cli_version_suffix}" ] || [ "${cli_version_suffix}" = "=" ] ; then
315+
err "No full or partial Docker / Moby version match found for \"${DOCKER_VERSION}\" on OS ${ID} ${VERSION_CODENAME} (${architecture}). Available versions:"
316+
apt-cache madison ${cli_package_name} | awk -F"|" '{print $2}' | grep -oP '^(.+:)?\K.+'
317+
exit 1
318+
fi
319+
echo "engine_version_suffix ${engine_version_suffix}"
320+
echo "cli_version_suffix ${cli_version_suffix}"
321321
fi
322322

323323
# Version matching for moby-buildx
324324
if [ "${USE_MOBY}" = "true" ]; then
325-
if [ "${MOBY_BUILDX_VERSION}" = "latest" ]; then
326-
# Empty, meaning grab whatever "latest" is in apt repo
327-
buildx_version_suffix=""
328-
else
329-
buildx_version_dot_escaped="${MOBY_BUILDX_VERSION//./\\.}"
330-
buildx_version_dot_plus_escaped="${buildx_version_dot_escaped//+/\\+}"
331-
buildx_version_regex="^(.+:)?${buildx_version_dot_plus_escaped}([\\.\\+ ~:-]|$)"
332-
set +e
333-
buildx_version_suffix="=$(apt-cache madison moby-buildx | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${buildx_version_regex}")"
334-
set -e
335-
if [ -z "${buildx_version_suffix}" ] || [ "${buildx_version_suffix}" = "=" ]; then
336-
err "No full or partial moby-buildx version match found for \"${MOBY_BUILDX_VERSION}\" on OS ${ID} ${VERSION_CODENAME} (${architecture}). Available versions:"
337-
apt-cache madison moby-buildx | awk -F"|" '{print $2}' | grep -oP '^(.+:)?\K.+'
338-
exit 1
339-
fi
340-
echo "buildx_version_suffix ${buildx_version_suffix}"
341-
fi
325+
if [ "${MOBY_BUILDX_VERSION}" = "latest" ]; then
326+
# Empty, meaning grab whatever "latest" is in apt repo
327+
buildx_version_suffix=""
328+
else
329+
buildx_version_dot_escaped="${MOBY_BUILDX_VERSION//./\\.}"
330+
buildx_version_dot_plus_escaped="${buildx_version_dot_escaped//+/\\+}"
331+
buildx_version_regex="^(.+:)?${buildx_version_dot_plus_escaped}([\\.\\+ ~:-]|$)"
332+
set +e
333+
buildx_version_suffix="=$(apt-cache madison moby-buildx | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${buildx_version_regex}")"
334+
set -e
335+
if [ -z "${buildx_version_suffix}" ] || [ "${buildx_version_suffix}" = "=" ]; then
336+
err "No full or partial moby-buildx version match found for \"${MOBY_BUILDX_VERSION}\" on OS ${ID} ${VERSION_CODENAME} (${architecture}). Available versions:"
337+
apt-cache madison moby-buildx | awk -F"|" '{print $2}' | grep -oP '^(.+:)?\K.+'
338+
exit 1
339+
fi
340+
echo "buildx_version_suffix ${buildx_version_suffix}"
341+
fi
342342
fi
343343

344344
install_docker_or_moby() {
@@ -385,15 +385,14 @@ if type docker > /dev/null 2>&1 && type dockerd > /dev/null 2>&1; then
385385
exit 1
386386
fi
387387

388-
# Install compose
389-
apt-get -y install --no-install-recommends moby-compose || \
390-
err "Package moby-compose (Docker Compose v2) not available for OS ${ID} ${VERSION_CODENAME} (${architecture}). Skipping."
391-
else
392-
if [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then
393-
apt-get -y install --no-install-recommends docker-ce-cli${cli_version_suffix} docker-ce${engine_version_suffix}
394-
# Install compose
395-
apt-mark hold docker-ce docker-ce-cli
396-
apt-get -y install --no-install-recommends docker-compose-plugin || echo "(*) Package docker-compose-plugin (Docker Compose v2) not available for OS ${ID} ${VERSION_CODENAME} (${architecture}). Skipping."
388+
# Install compose
389+
apt-get -y install --no-install-recommends moby-compose || \
390+
err "Package moby-compose (Docker Compose v2) not available for OS ${ID} ${VERSION_CODENAME} (${architecture}). Skipping."
391+
elif [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then
392+
apt-get -y install --no-install-recommends docker-ce-cli${cli_version_suffix} docker-ce${engine_version_suffix}
393+
# Install compose
394+
apt-mark hold docker-ce docker-ce-cli
395+
apt-get -y install --no-install-recommends docker-compose-plugin || echo "(*) Package docker-compose-plugin (Docker Compose v2) not available for OS ${ID} ${VERSION_CODENAME} (${architecture}). Skipping."
397396

398397

399398
elif [ "${USE_MOBY}" = "true" ] && { [ "$ID" = "fedora" ] || [ "$ID_LIKE" = "rhel" ]; }; then
@@ -443,20 +442,20 @@ EOF
443442
set -e
444443

445444
if [ $DOCKER_INSTALL_EXIT_CODE -ne 0 ] || ! command -v docker >/dev/null || ! command -v dockerd >/dev/null; then
446-
echo "⚠️ Docker CE installation appears incomplete or failed — falling back to Moby."
445+
echo "⚠️ Docker CE installation appears incomplete or failed — falling back to Moby."
447446

448-
install_docker_or_moby
447+
install_docker_or_moby
449448

450-
# Optional: symlink to match docker-ce command names
451-
ln -sf /usr/bin/moby-engine /usr/bin/dockerd || true
449+
# Optional: symlink to match docker-ce command names
450+
ln -sf /usr/bin/moby-engine /usr/bin/dockerd || true
452451
else
453-
echo "✅ Docker CE installed successfully!"
452+
echo "✅ Docker CE installed successfully!"
454453
fi
455454

456455
# Create docker group if missing
457456
if ! getent group docker > /dev/null; then
458-
echo "Creating 'docker' group..."
459-
groupadd docker
457+
echo "Creating 'docker' group..."
458+
groupadd docker
460459
fi
461460

462461
# Add user to docker group
@@ -466,16 +465,14 @@ EOF
466465

467466
# Final message
468467
echo "✅ Docker or Moby installed and user configured."
469-
else
470-
if { [ "$ID" = "fedora" ] || [ "$ID_LIKE" = "rhel" ]; }; then
471-
echo "❌ Unsupported OS or configuration. Exiting."
472-
exit 1
468+
else
469+
if { [ "$ID" = "fedora" ] || [ "$ID_LIKE" = "rhel" ]; }; then
470+
echo "❌ Unsupported OS or configuration. Exiting."
471+
exit 1
473472
fi
474-
fi
475-
echo "Finished installing Docker / Moby!"
473+
echo "Finished installing Docker / Moby!"
476474
fi
477475

478-
479476
docker_home="/usr/libexec/docker"
480477
cli_plugins_dir="${docker_home}/cli-plugins"
481478

@@ -796,4 +793,4 @@ chown ${USERNAME}:root /usr/local/share/docker-init.sh
796793
# Clean up
797794
rm -rf /var/lib/apt/lists/*
798795

799-
echo 'docker-in-docker-debian script has completed!'
796+
echo 'docker-in-docker-debian script has completed!'

0 commit comments

Comments
 (0)