Skip to content

Commit

Permalink
change for version
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravsaini04 committed Aug 28, 2024
1 parent 1300bf9 commit 9cde8c3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/docker-in-docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,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}
DOCKER_VERSION=${DOCKER_VERSION}
DOCKER_INSTALL_VERSION=${DOCKER_VERSION}
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} DOCKER_DEFAULT_IP6_TABLES=${DOCKER_DEFAULT_IP6_TABLES} DOCKER_VERSION=${DOCKER_VERSION} $(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} DOCKER_INSTALL_VERSION=${DOCKER_INSTALL_VERSION} $(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 @@ -563,12 +563,11 @@ dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAU
else
DEFAULT_ADDRESS_POOL="--default-address-pool $DOCKER_DEFAULT_ADDRESS_POOL"
fi
semver_regex="^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$"
if echo "$DOCKER_VERSION" | grep -Eq "$semver_regex"; then
major_version=$(echo $DOCKER_VERSION | cut -d. -f1)
if [ "$major_version" -le 20 ]; then
if [ $DOCKER_DEFAULT_IP6_TABLES = true ]; then
semver_regex="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$"
if echo "$DOCKER_INSTALL_VERSION" | grep -Eq "^-?[0-9]+$" || echo "$DOCKER_INSTALL_VERSION" | grep -Eq "$semver_regex"; then
major_version=$(echo $DOCKER_INSTALL_VERSION | cut -d. -f1)
if [ "$major_version" -le 26 ]; then
if [ "${DOCKER_DEFAULT_IP6_TABLES}" = true ]; then
mkdir -p /etc/docker
# Create the daemon.json file for enabling ip6tables
tee /etc/docker/daemon.json > /dev/null <<JSON_EOF
Expand Down
28 changes: 28 additions & 0 deletions test/docker-in-docker/docker_build_older_enable_ip6tables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

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

# Definition specific tests
check "docker-buildx" docker buildx version
check "docker-build" docker build ./
check "docker-buildx" bash -c "docker buildx version"
check "docker-buildx-path" bash -c "ls -la /usr/libexec/docker/cli-plugins/docker-buildx"
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

# Report result
reportResults
12 changes: 12 additions & 0 deletions test/docker-in-docker/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
},
"remoteUser": "node"
},
"docker_build_older_enable_ip6tables": {
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18",
"features": {
"docker-in-docker": {
"version": "20.10.24",
"moby": "false",
"dockerDashComposeVersion": "v2",
"ip6tables": true
}
},
"remoteUser": "node"
},
"docker_build_no_compose": {
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18",
"features": {
Expand Down

0 comments on commit 9cde8c3

Please sign in to comment.