Skip to content
Closed
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
5 changes: 5 additions & 0 deletions src/docker-in-docker/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
"type": "boolean",
"default": true,
"description": "Install Compose Switch (provided docker compose is available) which is a replacement to the Compose V1 docker-compose (python) executable. It translates the command line into Compose V2 docker compose then runs the latter."
},
"ip6tables": {
"type": "boolean",
"default": true,
"description": "Disable ip6tables"
}
},
"entrypoint": "/usr/local/share/docker-init.sh",
Expand Down
11 changes: 10 additions & 1 deletion src/docker-in-docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ INSTALL_DOCKER_COMPOSE_SWITCH="${INSTALLDOCKERCOMPOSESWITCH:-"true"}"
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="bookworm buster bullseye bionic focal jammy noble"
DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="bookworm buster bullseye bionic focal hirsute impish jammy noble"
IP6_TABLES="${IP6TABLES:-true}"

# Default: Exit on any failure.
set -e
Expand Down Expand Up @@ -480,11 +481,12 @@ set -e

AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION}
DOCKER_DEFAULT_ADDRESS_POOL=${DOCKER_DEFAULT_ADDRESS_POOL}
DOCKER_DEFAULT_IP6_TABLES=${IP6_TABLES}
EOF

tee -a /usr/local/share/docker-init.sh > /dev/null \
<< 'EOF'
dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAULT_ADDRESS_POOL=${DOCKER_DEFAULT_ADDRESS_POOL} $(cat << 'INNEREOF'
dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAULT_ADDRESS_POOL=${DOCKER_DEFAULT_ADDRESS_POOL} DOCKER_DEFAULT_IP6_TABLES=${DOCKER_DEFAULT_IP6_TABLES} $(cat << 'INNEREOF'
# explicitly remove dockerd and containerd PID file to ensure that it can start properly if it was stopped uncleanly
find /run /var/run -iname 'docker*.pid' -delete || :
find /run /var/run -iname 'container*.pid' -delete || :
Expand Down Expand Up @@ -561,6 +563,13 @@ dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAU
DEFAULT_ADDRESS_POOL="--default-address-pool $DOCKER_DEFAULT_ADDRESS_POOL"
fi

# Create the daemon.json file with the provided value
cat <<JSON_EOF > /etc/docker/daemon.json
{
"ip6tables": $DOCKER_DEFAULT_IP6_TABLES
}
JSON_EOF

# Start docker/moby engine
( dockerd $CUSTOMDNS $DEFAULT_ADDRESS_POOL > /tmp/dockerd.log 2>&1 ) &
INNEREOF
Expand Down
22 changes: 22 additions & 0 deletions test/docker-in-docker/dockerIp6tablesDisabledTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

ip6tablesCheck() {
if command -v ip6tables > /dev/null 2>&1; then
if ip6tables -L > /dev/null 2>&1; then
echo "✔️ ip6tables is enabled."
else
echo "❌ ip6tables is disabled."
fi
else
echo "❕ip6tables command not found. ❕"
fi
}

check "ip6tables" ip6tablesCheck

reportResults
22 changes: 22 additions & 0 deletions test/docker-in-docker/dockerIp6tablesEnabledTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

ip6tablesCheck() {
if command -v ip6tables > /dev/null 2>&1; then
if ip6tables -L > /dev/null 2>&1; then
echo "✔️ ip6tables is enabled."
else
echo "❌ ip6tables is disabled."
fi
else
echo "❕ip6tables command not found. ❕"
fi
}

check "ip6tables" ip6tablesCheck

reportResults
16 changes: 16 additions & 0 deletions test/docker-in-docker/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
}
}
},
"dockerIp6tablesDisabledTest": {
"image": "ubuntu:focal",
"features": {
"docker-in-docker": {
"ip6tables": false
}
}
},
"dockerIp6tablesEnabledTest": {
"image": "ubuntu:focal",
"features": {
"docker-in-docker": {
"ip6tables": true
}
}
},
"dockerDefaultAddressPool": {
"image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18",
"remoteUser": "node",
Expand Down