Skip to content

Add docker-in-docker azure_dns_override flag #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/docker-in-docker/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions src/docker-in-docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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.
Expand All @@ -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>
Expand Down Expand Up @@ -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"
Expand Down