aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/docker-in-docker/devcontainer-feature.json8
-rwxr-xr-xsrc/docker-in-docker/install.sh16
-rw-r--r--test/docker-in-docker/azureDnsAutoDetectionDisabled.sh12
-rw-r--r--test/docker-in-docker/azureDnsAutoDetectionEnabled.sh12
-rw-r--r--test/docker-in-docker/dockerDefaultAddressPool.sh12
-rw-r--r--test/docker-in-docker/scenarios.json29
6 files changed, 85 insertions, 4 deletions
diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json
index a8022cf..95a6a2c 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.7",
+ "version": "1.0.8",
"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.",
@@ -33,6 +33,12 @@
"type": "boolean",
"default": true,
"description": "Allow automatically setting the dockerd DNS server when the installation script detects it is running in Azure"
+ },
+ "dockerDefaultAddressPool": {
+ "type": "string",
+ "default": "",
+ "proposals": [],
+ "description": "Define default address pools for Docker networks. e.g. base=192.168.0.0/16,size=24"
}
},
"entrypoint": "/usr/local/share/docker-init.sh",
diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh
index c51e57c..fe4692f 100755
--- a/src/docker-in-docker/install.sh
+++ b/src/docker-in-docker/install.sh
@@ -12,6 +12,7 @@ DOCKER_VERSION=${VERSION:-"latest"} # The Docker/Moby Engine + CLI should match
USE_MOBY=${MOBY:-"true"}
DOCKER_DASH_COMPOSE_VERSION=${DOCKERDASHCOMPOSEVERSION:-"v1"} # v1 or v2
AZURE_DNS_AUTO_DETECTION=${AZUREDNSAUTODETECTION:-"true"}
+DOCKER_DEFAULT_ADDRESS_POOL=${DOCKERDEFAULTADDRESSPOOL}
ENABLE_NONROOT_DOCKER=${ENABLE_NONROOT_DOCKER:-"true"}
USERNAME=${USERNAME:-"automatic"}
@@ -325,12 +326,13 @@ tee /usr/local/share/docker-init.sh > /dev/null \
set -e
-AZURE_DNS_AUTO_DETECTION=$AZURE_DNS_AUTO_DETECTION
+AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION}
+DOCKER_DEFAULT_ADDRESS_POOL=${DOCKER_DEFAULT_ADDRESS_POOL}
EOF
tee -a /usr/local/share/docker-init.sh > /dev/null \
<< 'EOF'
-dockerd_start="$(cat << 'INNEREOF'
+dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAULT_ADDRESS_POOL=${DOCKER_DEFAULT_ADDRESS_POOL} $(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>
find /run /var/run -iname 'docker*.pid' -delete || :
@@ -377,10 +379,18 @@ dockerd_start="$(cat << 'INNEREOF'
echo "Not setting dockerd DNS manually."
CUSTOMDNS=""
fi
+
set -e
+ if [ -z "$DOCKER_DEFAULT_ADDRESS_POOL" ]
+ then
+ DEFAULT_ADDRESS_POOL=""
+ else
+ DEFAULT_ADDRESS_POOL="--default-address-pool $DOCKER_DEFAULT_ADDRESS_POOL"
+ fi
+
# Start docker/moby engine
- ( dockerd $CUSTOMDNS > /tmp/dockerd.log 2>&1 ) &
+ ( dockerd $CUSTOMDNS $DEFAULT_ADDRESS_POOL > /tmp/dockerd.log 2>&1 ) &
INNEREOF
)"
diff --git a/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh b/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh
new file mode 100644
index 0000000..d3f4159
--- /dev/null
+++ b/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+# Optional: Import test library
+source dev-container-features-test-lib
+
+# Definition specific tests
+check "dns flag should not be present" test ! "$(ps -ax | grep -E 'dockerd.+\-\-dns')"
+
+# Report result
+reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh b/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh
new file mode 100644
index 0000000..e63a1f3
--- /dev/null
+++ b/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+# Optional: Import test library
+source dev-container-features-test-lib
+
+# Definition specific tests
+check "dns flag should be present" ps -ax | grep -E "dockerd.+\-\-dns"
+
+# Report result
+reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/dockerDefaultAddressPool.sh b/test/docker-in-docker/dockerDefaultAddressPool.sh
new file mode 100644
index 0000000..8345357
--- /dev/null
+++ b/test/docker-in-docker/dockerDefaultAddressPool.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+# Optional: Import test library
+source dev-container-features-test-lib
+
+# Definition specific tests
+check "default address pool setting set" ps -ax | grep -E "dockerd.+base=192.168.0.0/16,size=24"
+
+# Report result
+reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/scenarios.json b/test/docker-in-docker/scenarios.json
new file mode 100644
index 0000000..d37053a
--- /dev/null
+++ b/test/docker-in-docker/scenarios.json
@@ -0,0 +1,29 @@
+{
+ "dockerDefaultAddressPool": {
+ "image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18",
+ "remoteUser": "node",
+ "features": {
+ "docker-in-docker": {
+ "dockerDefaultAddressPool": "base=192.168.0.0/16,size=24"
+ }
+ }
+ },
+ "azureDnsAutoDetectionEnabled": {
+ "image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18",
+ "remoteUser": "node",
+ "features": {
+ "docker-in-docker": {
+ "azureDnsAutoDetection": true
+ }
+ }
+ },
+ "azureDnsAutoDetectionDisabled": {
+ "image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18",
+ "remoteUser": "node",
+ "features": {
+ "docker-in-docker": {
+ "azureDnsAutoDetection": false
+ }
+ }
+ }
+} \ No newline at end of file