Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for debug python application in docker #2327

Closed
general03 opened this issue Sep 16, 2020 · 18 comments · Fixed by #3798
Closed

Error for debug python application in docker #2327

general03 opened this issue Sep 16, 2020 · 18 comments · Fixed by #3798

Comments

@general03
Copy link

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

@bwateratmsft
Copy link
Contributor

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

@general03
Copy link
Author

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

Docker 19.03.12, build 48a66213fe and Python 3.7

@bwateratmsft
Copy link
Contributor

I mean the VSCode extensions:
image

@general03
Copy link
Author

I mean the VSCode extensions:
image

Yes sur I got it

@bwateratmsft
Copy link
Contributor

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

@general03
Copy link
Author

general03 commented Sep 17, 2020

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

@bwateratmsft
Copy link
Contributor

bwateratmsft commented Sep 17, 2020

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.

@adamterrell
Copy link

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.

@adamterrell
Copy link

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.

@bwateratmsft
Copy link
Contributor

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

@adamterrell
Copy link

@bwateratmsft
Copy link
Contributor

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

@bwateratmsft
Copy link
Contributor

bwateratmsft commented Sep 17, 2020

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.

@adamterrell
Copy link

adamterrell commented Sep 20, 2020 via email

@dbreshears dbreshears added this to the 1.8.0 milestone Sep 23, 2020
@bwateratmsft
Copy link
Contributor

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

@bwateratmsft bwateratmsft modified the milestones: 1.8.0, 1.9.0 Oct 28, 2020
@bwateratmsft
Copy link
Contributor

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

@bwateratmsft
Copy link
Contributor

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

@bwateratmsft bwateratmsft removed this from the 1.10.0 milestone Jan 12, 2021
@bwateratmsft bwateratmsft removed the P2 label Jan 12, 2021
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 26, 2021
@bwateratmsft
Copy link
Contributor

It's been a long time, but we actually managed to fix this! I tracked it in #3641 and fixed in #3798.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants