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
894 stars 361 forks source link

docker in docker: Error: there is no registered task type 'docker-run' #489

Open cboostcvanrooijen opened 1 year ago

cboostcvanrooijen commented 1 year ago

When using the docker in docker feature docker tasks are not detected:

The output gives:

Error: there is no registered task type 'docker-build'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'docker-run'. Did you miss installing an extension that provides a corresponding task provider?

My suspicion is that the tasks.json is parsed before the addon is installed.

samruddhikhandale commented 1 year ago

Hi 👋

Can you help me with the repro steps? (Especially a snippet of tasks.json and .devcontainer)

cboostcvanrooijen commented 1 year ago

devcontainer:

{
    "name": "Python 3",
    // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
    "image": "mcr.microsoft.com/devcontainers/python:0-3.11",

    // Features to add to the dev container. More info: https://containers.dev/features.
    "features": {
        "ghcr.io/devcontainers/features/docker-in-docker:2": {}
    },

    // Configure tool-specific properties.
    "customizations": {
        // Configure properties specific to VS Code.
        "vscode": {
            "settings": {
        "python.linting.pylintEnabled": true
      },
            "extensions": [
                "dbaeumer.vscode-eslint"
            ]
        }
    }

tasks:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "docker-build",
            "label": "redacted1-build",
            "platform": "python",
            "dockerBuild": {
                "tag": "redacted2:latest",
                "dockerfile": "${workspaceFolder}/dockerredacted1/Dockerfile",
                "context": "${workspaceFolder}",
                "pull": true
            },
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "type": "docker-run",
            "label": "redacted1-run",
            "dockerRun": {
                "volumes": [
                ]
            },
            "dependsOn": [
                "redacted1-build"
            ],
            "python": {
                "file": "run.py"
            }
        }
    ]
}
cboostcvanrooijen commented 1 year ago

A fix is to reload the window using Developer: Reload. But if someone builds the container for the first time the python extension is not found at task detection.

samruddhikhandale commented 1 year ago

I could reproduce the same issue with your configuration.

I wonder if this issue is related to https://github.com/microsoft/vscode/issues/173184 and https://github.com/microsoft/vscode/issues/173384. Can you comment on the issues linked ?

cboostcvanrooijen commented 1 year ago

https://github.com/microsoft/vscode/issues/173384 seems to be related as it talks about timeouts. The problem is that the tasks are processed before the extensions are fully installed

cboostcvanrooijen commented 1 year ago

@samruddhikhandale is there any timeline on fixing this?

samruddhikhandale commented 1 year ago

The VS Code issues should provide a better timeline for the fix.

// cc @chrmarti

chrmarti commented 1 year ago

@cboostcvanrooijen Does it start working if you wait for the extension to finish installing or is the window reload the only workaround?

This might be a separate issue from the above linked ones in VS Code tasks. /cc @meganrogge

meganrogge commented 1 year ago

what version are you using? I believe this was already fixed, can you try insider's?

rubensa commented 1 month ago

@chrmarti I'm in a similar situation. In my case, the only workaround is to reload window.

In my case, I'm working in a multi-root workspace. In one root folder I have a type "shell" task that is run on "folderOpen" and in an other root folder I have some type "docker-compose" tasks.

The project is opened in a devcontainer environment.

When the devcontainer is build, the "shell" task is run and I can see following log in Tasks output:

Error: there is no registered task type 'docker-compose'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'docker-compose'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'docker-compose'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'docker-compose'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'docker-compose'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'docker-compose'. Did you miss installing an extension that provides a corresponding task provider?
Activating task providers java

If I open Terminal --> Run Task... only the "shell" one is included (despite I have waited and checked that all extensions have finished loading, specially the Docker extension).

If I run Develper: Reload Window, then all tasks are listed under Terminal --> Run Task....