From 329be8f0ec8f430e1b016fdb6a40f644d96d10f9 Mon Sep 17 00:00:00 2001 From: Kevin Klopfenstein Date: Wed, 5 Oct 2022 17:36:07 +0000 Subject: [PATCH 1/3] Add docker-in-docker Azure DNS override flag --- script-library/docker-in-docker-debian.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/script-library/docker-in-docker-debian.sh b/script-library/docker-in-docker-debian.sh index 429836ef40..bf62c25b35 100755 --- a/script-library/docker-in-docker-debian.sh +++ b/script-library/docker-in-docker-debian.sh @@ -7,13 +7,14 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md # Maintainer: The VS Code and Codespaces Teams # -# Syntax: ./docker-in-docker-debian.sh [enable non-root docker access flag] [non-root user] [use moby] [Engine/CLI Version] [Major version for docker-compose] +# Syntax: ./docker-in-docker-debian.sh [enable non-root docker access flag] [non-root user] [use moby] [Engine/CLI Version] [Major version for docker-compose] [azure DNS override] ENABLE_NONROOT_DOCKER=${1:-"true"} USERNAME=${2:-"automatic"} USE_MOBY=${3:-"true"} DOCKER_VERSION=${4:-"latest"} # The Docker/Moby Engine + CLI should match in version DOCKER_DASH_COMPOSE_VERSION=${5:-"v1"} # v1 or v2 +AZURE_DNS_OVERRIDE=${6:-"true"} MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal jammy" DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute impish jammy" @@ -316,7 +317,7 @@ if [ "${ENABLE_NONROOT_DOCKER}" = "true" ]; then fi tee /usr/local/share/docker-init.sh > /dev/null \ -<< 'EOF' +<< EOF #!/bin/sh #------------------------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -325,6 +326,10 @@ tee /usr/local/share/docker-init.sh > /dev/null \ set -e +AZURE_DNS_OVERRIDE=$AZURE_DNS_OVERRIDE +EOF + +tee -a ./docker-init.sh > /dev/null << 'EOF' dockerd_start="$(cat << 'INNEREOF' # explicitly remove dockerd and containerd PID file to ensure that it can start properly if it was stopped uncleanly # ie: docker kill @@ -364,7 +369,7 @@ dockerd_start="$(cat << 'INNEREOF' # Handle DNS set +e cat /etc/resolv.conf | grep -i 'internal.cloudapp.net' - if [ $? -eq 0 ] + if [ $? -eq 0 ] && [ $AZURE_DNS_OVERRIDE = "true" ] then echo "Setting dockerd Azure DNS." CUSTOMDNS="--dns 168.63.129.16" From dfa495ebdb9a65625083bb22160ba5ba21719e0a Mon Sep 17 00:00:00 2001 From: Kevin Klopfenstein Date: Thu, 6 Oct 2022 17:04:40 +0000 Subject: [PATCH 2/3] Resolving PR feedback --- script-library/docker-in-docker-debian.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script-library/docker-in-docker-debian.sh b/script-library/docker-in-docker-debian.sh index bf62c25b35..9fa8184b90 100755 --- a/script-library/docker-in-docker-debian.sh +++ b/script-library/docker-in-docker-debian.sh @@ -329,7 +329,8 @@ set -e AZURE_DNS_OVERRIDE=$AZURE_DNS_OVERRIDE EOF -tee -a ./docker-init.sh > /dev/null << 'EOF' +tee -a /usr/local/share/docker-init.sh > /dev/null \ +<< 'EOF' dockerd_start="$(cat << 'INNEREOF' # explicitly remove dockerd and containerd PID file to ensure that it can start properly if it was stopped uncleanly # ie: docker kill @@ -369,7 +370,7 @@ dockerd_start="$(cat << 'INNEREOF' # Handle DNS set +e cat /etc/resolv.conf | grep -i 'internal.cloudapp.net' - if [ $? -eq 0 ] && [ $AZURE_DNS_OVERRIDE = "true" ] + if [ $? -eq 0 ] && [ ${AZURE_DNS_OVERRIDE} = "true" ] then echo "Setting dockerd Azure DNS." CUSTOMDNS="--dns 168.63.129.16" From 51cdd0d59dc103eced267e943278da2d44b046d7 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Thu, 6 Oct 2022 10:27:09 -0700 Subject: [PATCH 3/3] change `AZURE_DNS_OVERRIDE` to a more descriptive name --- script-library/docker-in-docker-debian.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script-library/docker-in-docker-debian.sh b/script-library/docker-in-docker-debian.sh index 9fa8184b90..c9f891bbdf 100755 --- a/script-library/docker-in-docker-debian.sh +++ b/script-library/docker-in-docker-debian.sh @@ -7,14 +7,14 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md # Maintainer: The VS Code and Codespaces Teams # -# Syntax: ./docker-in-docker-debian.sh [enable non-root docker access flag] [non-root user] [use moby] [Engine/CLI Version] [Major version for docker-compose] [azure DNS override] +# Syntax: ./docker-in-docker-debian.sh [enable non-root docker access flag] [non-root user] [use moby] [Engine/CLI Version] [Major version for docker-compose] [azure DNS auto detection flag] ENABLE_NONROOT_DOCKER=${1:-"true"} USERNAME=${2:-"automatic"} USE_MOBY=${3:-"true"} DOCKER_VERSION=${4:-"latest"} # The Docker/Moby Engine + CLI should match in version DOCKER_DASH_COMPOSE_VERSION=${5:-"v1"} # v1 or v2 -AZURE_DNS_OVERRIDE=${6:-"true"} +AZURE_DNS_AUTO_DETECTION=${6:-"true"} MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal jammy" DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute impish jammy" @@ -326,7 +326,7 @@ tee /usr/local/share/docker-init.sh > /dev/null \ set -e -AZURE_DNS_OVERRIDE=$AZURE_DNS_OVERRIDE +AZURE_DNS_AUTO_DETECTION=$AZURE_DNS_AUTO_DETECTION EOF tee -a /usr/local/share/docker-init.sh > /dev/null \ @@ -370,7 +370,7 @@ dockerd_start="$(cat << 'INNEREOF' # Handle DNS set +e cat /etc/resolv.conf | grep -i 'internal.cloudapp.net' - if [ $? -eq 0 ] && [ ${AZURE_DNS_OVERRIDE} = "true" ] + if [ $? -eq 0 ] && [ ${AZURE_DNS_AUTO_DETECTION} = "true" ] then echo "Setting dockerd Azure DNS." CUSTOMDNS="--dns 168.63.129.16" @@ -402,4 +402,4 @@ EOF chmod +x /usr/local/share/docker-init.sh chown ${USERNAME}:root /usr/local/share/docker-init.sh -echo 'docker-in-docker-debian script has completed!' \ No newline at end of file +echo 'docker-in-docker-debian script has completed!'