Vscode-docker: Error for debug python application in docker

Created on 16 Sep 2020  Â·  17Comments  Â·  Source: microsoft/vscode-docker

Hi,

I write the launch.json file in my project

{
    "configurations": [
        {
            "name": "Docker: Python - Django",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "python": {
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}/app",
                        "remoteRoot": "/usr/src/app"
                    }
                ],
                "port": 8000,
                "projectType": "django",
                "django": true,
            },
        }
    ]
}

With this task.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "docker-build",
            "label": "docker-build",
            "platform": "python",
            "dockerBuild": {
                "tag": "myapp:latest",
                "dockerfile": "${workspaceFolder}/app/Dockerfile",
                "context": "${workspaceFolder}",
                "pull": true
            }
        },
        {
            "type": "docker-run",
            "label": "docker-run: debug",
            "dependsOn": [
                "docker-build"
            ],
            "python": {
                "args": [
                    "runserver",
                    "0.0.0.0:8000"
                ],
                "file": "manage.py"
            },
            "dockerRun": {
                "ports": [
                    {
                        "hostPort": 8000,
                        "containerPort": 8000
                    }
                ],
                "volumes": [
                    {
                        "containerPath": "/usr/src/app",
                        "localPath": "${workspaceFolder}/app"
                    }
                ]
            }
        }
    ]
}

The build works well without error and my container is up

After this build I get the message box error Invalid message 'either "program", "module", or "code" must be specified'

If I add "program", "module", or "code" attribut in launch.json, VSCode tell me that this key is not allowed.

What I miss ??

Thanks

Version: 1.49.0
Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
Date: 2020-09-10T13:20:50.359Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 4.19.0-10-amd64

Python Debug blocked

Most helpful comment

I found the issue. Basically, workspaces won't work well in this context. I'd recommend opening the folder containing the project rather than using workspaces.

I opened this issue in VSCode; without a fix for that we can't fix it here. We need to use the fetchTasks API instead of workspace config to successfully get the task information needed to enable this scenario.

All 17 comments

What version of the Docker extension and Python extension do you have?

What version of the Docker extension and Python extension do you have?

Docker 19.03.12, build 48a66213fe and Python 3.7

I mean the VSCode extensions:
image

I mean the VSCode extensions:
image

Yes sur I got it

Which version of the Docker and Python VSCode extensions do you have though?

Which version of the Docker and Python VSCode extensions do you have though?

Docker extension 1.50
Python extension v2020.8.108011

And I installed now the Docker extension 1.6 and the result is the same

Gotcha. Yeah, both of those are recent enough they should be fine. Can you share your Dockerfile? I see that your directory structure is a little different than the default so there may be something going wrong there.

I am having the same issue. I went through the hello_django tutorial from microsoft and then I wanted to go through the container tutorial but when I go into the Docker debug mode I get this error.

I just opened the project as a folder and not as a workspace. The debug then worked as expected. I suspect that the workspace settings have to be modified.

@adamterrell Good to know. Workspaces frequently cause issues. Can you share the containerization tutorial you were following?

Ok, I was able to reproduce this by creating a workspace. I'm taking a look now.

I found the issue. Basically, workspaces won't work well in this context. I'd recommend opening the folder containing the project rather than using workspaces.

I opened this issue in VSCode; without a fix for that we can't fix it here. We need to use the fetchTasks API instead of workspace config to successfully get the task information needed to enable this scenario.

Thank you.

On Thu, Sep 17, 2020 at 12:12 PM Brandon Waterloo [MSFT] <
[email protected]> wrote:

I found the issue. Basically, workspaces won't work well in this context.
I'd recommend opening the folder containing the project rather than using
workspaces.

I opened this issue https://github.com/microsoft/vscode/issues/106946
in VSCode; without a fix for that we can't fix it here.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode-docker/issues/2327#issuecomment-694338819,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABPPV2FRBQOFVGXHSAZAXGDSGIYQTANCNFSM4RPJCOPQ
.

The upstream VSCode issue has been moved to the November milestone so I'll move this to our 1.9.0 milestone.

This may be solvable with #2289, if we (potentially) no longer need to build up a task tree.

The upstream issue blocking this in VSCode has been closed, so unfortunately we will not be able to fix this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kludex picture Kludex  Â·  7Comments

yusufkaratoprak picture yusufkaratoprak  Â·  4Comments

calbot picture calbot  Â·  7Comments

SQLvariant picture SQLvariant  Â·  3Comments

sajayantony picture sajayantony  Â·  6Comments