devcontainers / features

A collection of Dev Container Features managed by Dev Container spec maintainers. See https://github.com/devcontainers/feature-starter to publish your own
https://containers.dev/features
MIT License
820 stars 319 forks source link

`docker-in-docker` unable to install Docker above v20.10.x #607

Closed tschaffter closed 1 year ago

tschaffter commented 1 year ago

First, thank you a lot for developing this feature!

We have been using the docker-in-docker for about 6 months now. The version of Docker 20.10.21 does not provide the command docker scan so I attempted to update Docker to a more recent version. I first tried to specify the latest Docker version (24.0.3), which failed. I then tried the latest 23.x version (23.0.6), which also failed. The next version is back to 20.10, which works.

Note I'm wondering where the Docker version 21.x and 22.x went. :-)

image

Here is the error thrown by VS Code when trying to build a dev container with:

  "features": {
    "ghcr.io/devcontainers/features/docker-in-docker:2.2.0": {
      "version": "24.0.3"
    }
  },

Error:

...
[2023-07-07T15:32:39.873Z] (!) No full or partial Docker / Moby version match found for "24.0.3" on OS debian bullseye (amd64). Available versions:
[2023-07-07T15:32:40.414Z]  20.10.25+azure-debian11u2 
 20.10.25+azure-debian11u1 
 20.10.24+azure-debian11u1 
 20.10.23+azure-debian11u2 
 20.10.22+azure-debian11u1 
 20.10.21+azure-debian11u2 
 20.10.21+azure-debian11u1 
 20.10.20+azure-debian11u1 
 20.10.18+azure-debian11u2 
 20.10.18+azure-debian11u1 
 20.10.17+azure-debian11u1 
 20.10.16+azure-3 
 20.10.15+azure-1 
 20.10.14+azure-1 
 20.10.13+azure-1 
 20.10.11+azure-3 
 20.10.11+azure-2 
 20.10.11+azure-1 
 20.10.10+azure-1 
 20.10.9+azure-1 
 20.10.8+azure-1 
[2023-07-07T15:32:40.414Z] ERROR: Feature "Docker (Docker-in-Docker)" (ghcr.io/devcontainers/features/docker-in-docker) failed to install! Look at the documentation at https://github.com/devcontainers/features/tree/main/src/docker-in-docker for help troubleshooting this error.
[2023-07-07T15:32:40.702Z] The command '/bin/bash -euxo pipefail -c chmod -R 0755 /tmp/dev-container-features/docker-in-docker_0 && cd /tmp/dev-container-features/docker-in-docker_0 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh' returned a non-zero code: 1
[2023-07-07T15:32:40.704Z] Stop (64808 ms): Run: docker build --build-arg _DEV_CONTAINERS_BASE_IMAGE=sagebionetworks/sage-devcontainer:e045b26 --build-arg _DEV_CONTAINERS_IMAGE_USER=vscode --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-sage-monorepo-ed241d52c3a885a9465036af5e1e9772d977ec3ac0ad24e6aafe29f0cfcbc9ca-features -f /tmp/devcontainercli-ec2-user/container-features/0.46.0-1688743894974/Dockerfile.extended /tmp/devcontainercli-ec2-user/empty-folder
[2023-07-07T15:32:40.646Z] Error: Command failed: docker build --build-arg _DEV_CONTAINERS_BASE_IMAGE=sagebionetworks/sage-devcontainer:e045b26 --build-arg _DEV_CONTAINERS_IMAGE_USER=vscode --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-sage-monorepo-ed241d52c3a885a9465036af5e1e9772d977ec3ac0ad24e6aafe29f0cfcbc9ca-features -f /tmp/devcontainercli-ec2-user/container-features/0.46.0-1688743894974/Dockerfile.extended /tmp/devcontainercli-ec2-user/empty-folder
[2023-07-07T15:32:40.647Z]     at Mte (/home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js:2007:1066)
[2023-07-07T15:32:40.647Z]     at n3 (/home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js:2007:1002)
[2023-07-07T15:32:40.647Z]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-07-07T15:32:40.648Z]     at async rre (/home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js:2024:3660)
[2023-07-07T15:32:40.648Z]     at async Yf (/home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js:2024:4775)
[2023-07-07T15:32:40.649Z]     at async Dne (/home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js:2156:12193)
[2023-07-07T15:32:40.649Z]     at async Sne (/home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js:2156:11934)
[2023-07-07T15:32:40.651Z] Stop (66429 ms): Run in Host: /home/ec2-user/.vscode-server/bin/695af097c7bd098fbf017ce3ac85e09bbc5dda06/node /home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-60dff176-44de-4500-936b-957a92ae06d41688743886141 --workspace-folder /home/ec2-user/sage-monorepo --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/ec2-user/sage-monorepo --id-label devcontainer.config_file=/home/ec2-user/sage-monorepo/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/ec2-user/sage-monorepo/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-07-07T15:32:40.652Z] Exit code 1
[2023-07-07T15:32:40.656Z] Command failed: /home/ec2-user/.vscode-server/bin/695af097c7bd098fbf017ce3ac85e09bbc5dda06/node /home/ec2-user/.vscode-remote-containers/dist/dev-containers-cli-0.299.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-60dff176-44de-4500-936b-957a92ae06d41688743886141 --workspace-folder /home/ec2-user/sage-monorepo --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/ec2-user/sage-monorepo --id-label devcontainer.config_file=/home/ec2-user/sage-monorepo/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/ec2-user/sage-monorepo/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-07-07T15:32:40.656Z] Exit code 1

The version of Docker installed on the host is Docker version 20.10.17, build 100c701. My understanding from the README of docker-in-docker is that the version of Docker installed with docker-in-docker is independent from the host's docker instance. However, there still seems to be some dependency as the Limitations section says:

the Feature is expected to work when the host is running Docker

samruddhikhandale commented 1 year ago

Hi 👋

Thanks for opening the issue, I was able to reproduce the error with the provided configuration.

@tschaffter can you try with "moby": false? It fixed my issue.

Reasoning: If moby:true, it installs from Micrsoft apt repo which does not contain the latest versions. However, with moby:false, it installs from Docker ap repo (which works)

"features": {
    "ghcr.io/devcontainers/features/docker-in-docker:2.2.0": {
        "version": "24.0.3",
        "moby": false
    }
}
tschaffter commented 1 year ago

Specifying moby: false works. Thanks @samruddhikhandale

$ docker exec -it sage_devcontainer docker --version
Docker version 24.0.3, build 3713ee1