aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Klopfenstein <kklopfenstein@users.noreply.github.com>2022-10-06 20:54:20 +0300
committerGitHub <noreply@github.com>2022-10-06 20:54:20 +0300
commita9441adf0e023605d6afbbacfd9521634e02a59a (patch)
treec94864923f4c3ad15cb83a74c525ecb81e4fb30b
parent82960fd16b04fb4003a8765b2381bd23553737b5 (diff)
Add docker-in-docker azure_dns_override flag (#200)
* Add docker-in-docker azure_dns_overrideflag * Update install.sh * clarify variable name * update option name and description for `azureDnsAutoDetection` * bump feature version Co-authored-by: Josh Spicer <josh@joshspicer.com>
-rw-r--r--src/docker-in-docker/devcontainer-feature.json7
-rwxr-xr-xsrc/docker-in-docker/install.sh10
2 files changed, 14 insertions, 3 deletions
diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json
index ea8a6df..8538b46 100644
--- a/src/docker-in-docker/devcontainer-feature.json
+++ b/src/docker-in-docker/devcontainer-feature.json
@@ -1,6 +1,6 @@
{
"id": "docker-in-docker",
- "version": "1.0.4",
+ "version": "1.0.5",
"name": "Docker (Docker-in-Docker)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-in-docker",
"description": "Create child containers *inside* a container, independent from the host's docker instance. Installs Docker extension in the container along with needed CLIs.",
@@ -28,6 +28,11 @@
],
"default": "v1",
"description": "Default version of Docker Compose (v1 or v2)"
+ },
+ "azureDnsAutoDetection": {
+ "type": "boolean",
+ "default": true,
+ "description": "Allow automatically setting the dockerd DNS server when the installation script detects it is running in Azure"
}
},
"entrypoint": "/usr/local/share/docker-init.sh",
diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh
index a67aaba..afcdc1a 100755
--- a/src/docker-in-docker/install.sh
+++ b/src/docker-in-docker/install.sh
@@ -11,6 +11,7 @@
DOCKER_VERSION=${VERSION:-"latest"} # The Docker/Moby Engine + CLI should match in version
USE_MOBY=${MOBY:-"true"}
DOCKER_DASH_COMPOSE_VERSION=${DOCKERDASHCOMPOSEVERSION:-"v1"} # v1 or v2
+AZURE_DNS_AUTO_DETECTION=${AZUREDNSAUTODETECTION:-"true"}
ENABLE_NONROOT_DOCKER=${ENABLE_NONROOT_DOCKER:-"true"}
USERNAME=${USERNAME:-"automatic"}
@@ -312,7 +313,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.
@@ -321,6 +322,11 @@ tee /usr/local/share/docker-init.sh > /dev/null \
set -e
+AZURE_DNS_AUTO_DETECTION=$AZURE_DNS_AUTO_DETECTION
+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 <ID>
@@ -360,7 +366,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_AUTO_DETECTION} = "true" ]
then
echo "Setting dockerd Azure DNS."
CUSTOMDNS="--dns 168.63.129.16"