我可以创建一个测试回购,如果需要的话。但这个问题的要点是,当我使用
up
run
命令。在这两种情况下,我都可以看到我的应用程序启动。vs代码调试器在使用时似乎无法连接到docker容器
docker-compose run
.
这类似于我在vs代码中的工作启动任务(调试器可以连接到该任务):
{
"type": "node",
"request": "launch",
"name": "Docker: Debug",
"runtimeExecutable": "docker-compose",
"runtimeArgs": [
"up"
],
"port": 9229,
"stopOnEntry": true,
"restart": true,
"timeout": 30000,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/app",
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ],
"console": "externalTerminal",
"internalConsoleOptions": "neverOpen",
"protocol": "inspector",
"showAsyncStacks": true
}
npm run start-app
,例如)
start-app
具有以下定义:
nodemon --legacy-watch --watch ./dist/app1 --inspect=0.0.0.0:9229 --nolazy ./dist/app1/index.js
docker-compose.yml
我希望能够运行容器并指定在我的vs代码中运行哪个应用程序
launch.json
文件,如下所示:
{
"type": "node",
"request": "launch",
"name": "Docker: Debug",
"runtimeExecutable": "docker-compose",
"runtimeArgs": [
"run",
"all",
"npm",
"run",
"start-app"
],
"port": 9229,
"stopOnEntry": true,
"restart": true,
"timeout": 30000,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/app",
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ],
"console": "externalTerminal",
"internalConsoleOptions": "neverOpen",
"protocol": "inspector",
"showAsyncStacks": true
}
仅供参考
all
在arg列表中引用
文件。