我正在尝试在带有 VSCode 的 docker 容器中使用 dlv 运行远程调试。当我指定 docker-compose 标志network_mode: host而不是特定端口时,问题就开始了(由于使用 MQTT,这是必需的)。这会导致 VSCode 抛出以下错误:“无法继续:“错误:连接 ENCONNREFUSED ...””
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Remote Docker",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath":"/go/src/work/cmd/mapper",
"port": 2345,
// "host": "127.0.0.1",
"cwd": "${workspaceFolder}/src/cmd/mapper",
"args": [],
"trace" : "verbose",
"env" : {}
},
]
}
码头工人-compose.yml
version: "3.4"
services:
golang:
container_name: golang
image: gotestdlv:latest
privileged: true
volumes:
- ./src/:/go/src/work/
network_mode: host
# ports:
# - 2345:2345 # debug port
温温酱
相关分类