From 9cde8c372c21b284a9403b1869ec7a5830eff1c4 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:54:12 +0000 Subject: [PATCH] change for version --- src/docker-in-docker/install.sh | 15 +++++----- .../docker_build_older_enable_ip6tables.sh | 28 +++++++++++++++++++ test/docker-in-docker/scenarios.json | 12 ++++++++ 3 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 test/docker-in-docker/docker_build_older_enable_ip6tables.sh diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index d3f49a40a..cf8f9c24c 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -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 || : @@ -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 < /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 \ No newline at end of file diff --git a/test/docker-in-docker/scenarios.json b/test/docker-in-docker/scenarios.json index 77692c41e..58bde9616 100644 --- a/test/docker-in-docker/scenarios.json +++ b/test/docker-in-docker/scenarios.json @@ -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": {