Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
4d91590448 | ||
|
c26c541493 |
5 changed files with 54 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"id": "docker-in-docker",
|
"id": "docker-in-docker",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"name": "Docker (Docker-in-Docker)",
|
"name": "Docker (Docker-in-Docker)",
|
||||||
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/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.",
|
"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",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
"description": "Allow automatically setting the dockerd DNS server when the installation script detects it is running in Azure"
|
"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",
|
"entrypoint": "/usr/local/share/docker-init.sh",
|
||||||
|
|
|
@ -12,6 +12,7 @@ DOCKER_VERSION=${VERSION:-"latest"} # The Docker/Moby Engine + CLI should match
|
||||||
USE_MOBY=${MOBY:-"true"}
|
USE_MOBY=${MOBY:-"true"}
|
||||||
DOCKER_DASH_COMPOSE_VERSION=${DOCKERDASHCOMPOSEVERSION:-"v1"} # v1 or v2
|
DOCKER_DASH_COMPOSE_VERSION=${DOCKERDASHCOMPOSEVERSION:-"v1"} # v1 or v2
|
||||||
AZURE_DNS_AUTO_DETECTION=${AZUREDNSAUTODETECTION:-"true"}
|
AZURE_DNS_AUTO_DETECTION=${AZUREDNSAUTODETECTION:-"true"}
|
||||||
|
DOCKER_DEFAULT_ADDRESS_POOL=${DOCKERDEFAULTADDRESSPOOL}
|
||||||
|
|
||||||
ENABLE_NONROOT_DOCKER=${ENABLE_NONROOT_DOCKER:-"true"}
|
ENABLE_NONROOT_DOCKER=${ENABLE_NONROOT_DOCKER:-"true"}
|
||||||
USERNAME=${USERNAME:-"automatic"}
|
USERNAME=${USERNAME:-"automatic"}
|
||||||
|
@ -325,12 +326,13 @@ tee /usr/local/share/docker-init.sh > /dev/null \
|
||||||
|
|
||||||
set -e
|
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
|
EOF
|
||||||
|
|
||||||
tee -a /usr/local/share/docker-init.sh > /dev/null \
|
tee -a /usr/local/share/docker-init.sh > /dev/null \
|
||||||
<< 'EOF'
|
<< '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
|
# explicitly remove dockerd and containerd PID file to ensure that it can start properly if it was stopped uncleanly
|
||||||
# ie: docker kill <ID>
|
# ie: docker kill <ID>
|
||||||
find /run /var/run -iname 'docker*.pid' -delete || :
|
find /run /var/run -iname 'docker*.pid' -delete || :
|
||||||
|
@ -377,10 +379,18 @@ dockerd_start="$(cat << 'INNEREOF'
|
||||||
echo "Not setting dockerd DNS manually."
|
echo "Not setting dockerd DNS manually."
|
||||||
CUSTOMDNS=""
|
CUSTOMDNS=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
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
|
# Start docker/moby engine
|
||||||
( dockerd $CUSTOMDNS > /tmp/dockerd.log 2>&1 ) &
|
( dockerd $CUSTOMDNS $DEFAULT_ADDRESS_POOL > /tmp/dockerd.log 2>&1 ) &
|
||||||
INNEREOF
|
INNEREOF
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
|
19
test/docker-in-docker/dockerDefaultAddressPool.sh
Normal file
19
test/docker-in-docker/dockerDefaultAddressPool.sh
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Optional: Import test library
|
||||||
|
source dev-container-features-test-lib
|
||||||
|
|
||||||
|
# Definition specific tests
|
||||||
|
check "version" docker --version
|
||||||
|
|
||||||
|
check "ps" docker ps
|
||||||
|
|
||||||
|
check "run hello world" docker run hello-world
|
||||||
|
|
||||||
|
# Asserts specific to manually setting dockerDefaultAddressPool
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# Report result
|
||||||
|
reportResults
|
11
test/docker-in-docker/scenarios.json
Normal file
11
test/docker-in-docker/scenarios.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"dockerDefaultAddressPool": {
|
||||||
|
"image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18",
|
||||||
|
"remoteUser": "node",
|
||||||
|
"features": {
|
||||||
|
"docker-in-docker": {
|
||||||
|
"dockerDefaultAddressPool": "192.168.0.0/16,size=24"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,5 +8,9 @@ source dev-container-features-test-lib
|
||||||
# Definition specific tests
|
# Definition specific tests
|
||||||
check "version" docker --version
|
check "version" docker --version
|
||||||
|
|
||||||
|
check "ps" docker ps
|
||||||
|
|
||||||
|
check "run hello world" docker run hello-world
|
||||||
|
|
||||||
# Report result
|
# Report result
|
||||||
reportResults
|
reportResults
|
Loading…
Reference in a new issue