From a8dc2dbb5909de35662067bb9428a7aafc10d3fe Mon Sep 17 00:00:00 2001 From: Samruddhi Khandale Date: Mon, 26 Feb 2024 09:28:00 -0800 Subject: [PATCH] Docker: Unpin "mobyBuildxVersion" (#877) --- .../devcontainer-feature.json | 6 +++--- src/docker-in-docker/install.sh | 14 +++++++------ .../devcontainer-feature.json | 6 +++--- src/docker-outside-of-docker/install.sh | 2 +- .../docker_specific_moby_buildx.sh | 20 +++++++++++++++++++ test/docker-in-docker/scenarios.json | 8 ++++++++ test/docker-in-docker/test.sh | 1 + .../docker_specific_moby_buildx.sh | 19 ++++++++++++++++++ test/docker-outside-of-docker/scenarios.json | 8 ++++++++ test/docker-outside-of-docker/test.sh | 1 + 10 files changed, 72 insertions(+), 13 deletions(-) create mode 100755 test/docker-in-docker/docker_specific_moby_buildx.sh create mode 100755 test/docker-outside-of-docker/docker_specific_moby_buildx.sh diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json index 5c62a057d..d74f205a1 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": "2.9.1", + "version": "2.9.2", "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.", @@ -22,8 +22,8 @@ }, "mobyBuildxVersion": { "type": "string", - "default": "0.12.0", - "description": "Install a specific version of moby-buildx when using Moby. (2024-02-09: Microsoft's Package Manifest has mismatching filesize and SHA for 0.12.1; default is last known good version)" + "default": "latest", + "description": "Install a specific version of moby-buildx when using Moby" }, "dockerDashComposeVersion": { "type": "string", diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index 889d1dbb2..9f0e18cee 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -10,7 +10,7 @@ DOCKER_VERSION="${VERSION:-"latest"}" # The Docker/Moby Engine + CLI should match in version USE_MOBY="${MOBY:-"true"}" -MOBY_BUILDX_VERSION="${MOBYBUILDXVERSION:-"0.12.0"}" +MOBY_BUILDX_VERSION="${MOBYBUILDXVERSION:-"latest"}" DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"v1"}" # v1 or v2 or none AZURE_DNS_AUTO_DETECTION="${AZUREDNSAUTODETECTION:-"true"}" DOCKER_DEFAULT_ADDRESS_POOL="${DOCKERDEFAULTADDRESSPOOL:-""}" @@ -228,11 +228,13 @@ else # Install engine set +e # Handle error gracefully apt-get -y install --no-install-recommends moby-cli${cli_version_suffix} moby-buildx${buildx_version_suffix} moby-engine${engine_version_suffix} - if [ $? -ne 0 ]; then - err "Packages for moby not available in OS ${ID} ${VERSION_CODENAME} (${architecture}). To resolve, either: (1) set feature option '\"moby\": false' , or (2) choose a compatible OS version (eg: 'ubuntu-20.04')." - exit 1 - fi - set -e + exit_code=$? + set -e + + if [ ${exit_code} -ne 0 ]; then + err "Packages for moby not available in OS ${ID} ${VERSION_CODENAME} (${architecture}). To resolve, either: (1) set feature option '\"moby\": false' , or (2) choose a compatible OS version (eg: 'ubuntu-20.04')." + exit 1 + fi # Install compose apt-get -y install --no-install-recommends moby-compose || err "Package moby-compose (Docker Compose v2) not available for OS ${ID} ${VERSION_CODENAME} (${architecture}). Skipping." diff --git a/src/docker-outside-of-docker/devcontainer-feature.json b/src/docker-outside-of-docker/devcontainer-feature.json index a17757c06..d4c1447ba 100644 --- a/src/docker-outside-of-docker/devcontainer-feature.json +++ b/src/docker-outside-of-docker/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "docker-outside-of-docker", - "version": "1.4.1", + "version": "1.4.2", "name": "Docker (docker-outside-of-docker)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-outside-of-docker", "description": "Re-use the host docker socket, adding the Docker CLI to a container. Feature invokes a script to enable using a forwarded Docker socket within a container to run Docker commands.", @@ -22,8 +22,8 @@ }, "mobyBuildxVersion": { "type": "string", - "default": "0.12.0", - "description": "Install a specific version of moby-buildx when using Moby. (2024-02-09: Microsoft's Package Manifest has mismatching filesize and SHA for 0.12.1; default is last known good version)" + "default": "latest", + "description": "Install a specific version of moby-buildx when using Moby" }, "dockerDashComposeVersion": { "type": "string", diff --git a/src/docker-outside-of-docker/install.sh b/src/docker-outside-of-docker/install.sh index da936235c..65424740e 100755 --- a/src/docker-outside-of-docker/install.sh +++ b/src/docker-outside-of-docker/install.sh @@ -9,7 +9,7 @@ DOCKER_VERSION="${VERSION:-"latest"}" USE_MOBY="${MOBY:-"true"}" -MOBY_BUILDX_VERSION="${MOBYBUILDXVERSION:-"0.12.0"}" +MOBY_BUILDX_VERSION="${MOBYBUILDXVERSION:-"latest"}" DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"v1"}" # v1 or v2 or none ENABLE_NONROOT_DOCKER="${ENABLE_NONROOT_DOCKER:-"true"}" diff --git a/test/docker-in-docker/docker_specific_moby_buildx.sh b/test/docker-in-docker/docker_specific_moby_buildx.sh new file mode 100755 index 000000000..1ca2b20bd --- /dev/null +++ b/test/docker-in-docker/docker_specific_moby_buildx.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib +# Definition specific tests +check "moby-buildx" bash -c "dpkg-query -W moby-buildx | grep -E '0.12.0'" + +check "docker-buildx" bash -c "docker buildx version" +check "docker-buildx-path" bash -c "ls -la /usr/libexec/docker/cli-plugins/docker-buildx" + +check "docker-buildx" docker buildx version +check "docker-build" docker build ./ + +check "installs docker-compose v1 install" bash -c "type docker-compose" +check "installs compose-switch" bash -c "[[ -f /usr/local/bin/compose-switch ]]" + +# Report result +reportResults diff --git a/test/docker-in-docker/scenarios.json b/test/docker-in-docker/scenarios.json index df27d6c28..ccf57b188 100644 --- a/test/docker-in-docker/scenarios.json +++ b/test/docker-in-docker/scenarios.json @@ -98,6 +98,14 @@ } } }, + "docker_specific_moby_buildx": { + "image": "ubuntu:focal", + "features": { + "docker-in-docker": { + "mobyBuildxVersion": "0.12.0" + } + } + }, // DO NOT REMOVE: This scenario is used by the docker-in-docker-stress-test workflow "docker_with_on_create_command": { "image": "mcr.microsoft.com/devcontainers/base:debian", diff --git a/test/docker-in-docker/test.sh b/test/docker-in-docker/test.sh index e86a841c2..10a7232b6 100755 --- a/test/docker-in-docker/test.sh +++ b/test/docker-in-docker/test.sh @@ -12,6 +12,7 @@ check "docker-ps" bash -c "docker ps" check "log-exists" bash -c "ls /tmp/dockerd.log" check "log-for-completion" bash -c "cat /tmp/dockerd.log | grep 'Daemon has completed initialization'" check "log-contents" bash -c "cat /tmp/dockerd.log | grep 'API listen on /var/run/docker.sock'" +check "moby-buildx" bash -c "dpkg-query -W moby-buildx" # Report result reportResults \ No newline at end of file diff --git a/test/docker-outside-of-docker/docker_specific_moby_buildx.sh b/test/docker-outside-of-docker/docker_specific_moby_buildx.sh new file mode 100755 index 000000000..929fa6080 --- /dev/null +++ b/test/docker-outside-of-docker/docker_specific_moby_buildx.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib +# Definition specific tests +check "moby-buildx" bash -c "dpkg-query -W moby-buildx | grep -E '0.12.0'" + +check "docker-buildx" bash -c "docker buildx version" +check "docker-buildx-path" bash -c "ls -la /usr/libexec/docker/cli-plugins/docker-buildx" + +check "docker-buildx" docker buildx version +check "docker-build" docker build ./ + +check "installs docker-compose v1 install" bash -c "type docker-compose" + +# Report result +reportResults diff --git a/test/docker-outside-of-docker/scenarios.json b/test/docker-outside-of-docker/scenarios.json index 3b82c6cc5..61f1ab402 100644 --- a/test/docker-outside-of-docker/scenarios.json +++ b/test/docker-outside-of-docker/scenarios.json @@ -124,5 +124,13 @@ } }, "remoteUser": "node" + }, + "docker_specific_moby_buildx": { + "image": "ubuntu:focal", + "features": { + "docker-outside-of-docker": { + "mobyBuildxVersion": "0.12.0" + } + } } } diff --git a/test/docker-outside-of-docker/test.sh b/test/docker-outside-of-docker/test.sh index fe9098e10..5206f5977 100644 --- a/test/docker-outside-of-docker/test.sh +++ b/test/docker-outside-of-docker/test.sh @@ -10,6 +10,7 @@ check "docker compose" bash -c "docker compose version" check "docker-compose" bash -c "docker-compose --version" check "docker-ps" bash -c "docker ps >/dev/null" +check "moby-buildx" bash -c "dpkg-query -W moby-buildx" # Report result reportResults \ No newline at end of file