我正在做一个项目,我们用docker来开发一个应用程序。目前,我正在通过在控制台中键入docker-compose run --rm app来运行程序。然后我可以像这样运行我的root@ce4d1325fb94:/home/app# python3 example.py,但是我想使用我的调试器。通常情况下,我可以使用它按F5。我发现了这个:https://code.visualstudio.com/docs/containers/debug-common和这个:https://code.visualstudio.com/docs/containers/debug-python,但是id不起作用。我得到了错误Could not find the task 'docker-run: debug'或ConfigError: The project 'Projekte_635c102' is not a valid java project.
我做错了什么?注意:我不知道码头到底是什么。我被告知要使用它。
编辑:我做的每件事都和@明杰-MSFT说的一模一样。它仍然得到相同的Could not find the task 'docker-run: debug'错误。我不能创造一个例子,因为我不知道我在做什么。我从来没有和码头工人合作过,也没有得到如何使用它的解释。我刚被告知要使用现有的代码。如果有什么帮助的话,我可以把文件给你。
# syntax=docker/dockerfile:1
FROM ubuntu:latest
WORKDIR /home/app
# Pass 8 and 63 to tzdata to set up the default time zone
RUN apt-get update && echo 8 63 | apt-get install -y tzdata
RUN apt-get install -y python3-pip libgdal-dev gdal-bin default-jre && pip3 install -r requirements.txt在容器中时,我还尝试在控制台中输入docker-run: debug。
root@cd70584fb560:/home/app# docker-run debug而且我有
bash: docker-run: command not found我试图在我的launch.json中包括一个launch.json。但同样没有运气。我想,也许它是在试图找到以前在"preLaunchTask"中指定的launch.json。再说一次,我在这里完全没有头绪。对于这个launch.json应该如何工作的任何解释都是非常感谢的。这些命令应该做什么?我只知道一点python,对使用命令行命令几乎一无所知。
{
"configurations": [
{
"name": "Docker: Python - Django",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "django"
}
}
],
"tasks": [
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": ["docker-build"],
"python": {
"args": ["runserver", "0.0.0.0:8000", "--nothreading", "--noreload"],
"file": "manage.py" // how to I change this to current file?
}
}
]
}发布于 2022-10-17 03:15:49
阅读有关在坞中调试的文档。
ConfigError:项目'Projekte_635c102‘不是一个有效的java项目。
它将您的项目标识为java项目。您的launch.json似乎犯了错误。检查一下你的launch.json。它应该是这样的:
{
"configurations": [
{
"name": "Docker: Python - Django",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "django"
}
}
]
}

https://stackoverflow.com/questions/74082123
复制相似问题