Debug in local docker, refuse connecting
Answered
My company provides a docker image for development, but does not have dlv installed.
I can run my program via Run, but not via Debug, both of which run on docker.
I think the reason might be that this image does not have dlv installed.
I don't know if Goland debug on Docker requires the container to have dlv installed?
Also, I don't know how to add dlv to a special version of a packaged image.
Finally, I found out that vscode has an extension to help debugging on docker without installing dlv! You can refer to https://github.com/golang/vscode-go/wiki/debugging#connecting-to-headless-delve-with-target-specified-at-server-start-up.
Does Goland have a similar feature?
Please sign in to leave a comment.
GoLand should be able to move dlv from your local machine to the container.
May I ask you to share the output of Run tool window after pressing Debug button?
I follow this guide (https://www.jetbrains.com/help/go/run-targets.html#docker) still not working, this is the output
these are my config
Also, I wonder what this means? Is it possible to use an existing container instead of running a new one?
I'm using VScode too, VScode can debug in existing container, directly
Please reproduce the issue, collect the IDE logs via Help | Collect Logs and Diagnostic Data, upload them to https://uploads.jetbrains.com/ and provide the ID. I see that debugger starts in a container but does not trigger breakpoints for some reason.
Also, please keep in mind that your container should have GLIBC library and you can install it via RUN sudo apt install libc6.
It's not possible at the moment, please follow IDEA-285716.
Best Regards,
Daniil Maslov
JetBrains
No, not working
I mean to add it before `dlv` execution e.g. `CGO_ENABLED=0 ./dlv` in a Docker container. Did you receive the same error?
If so, please isolate it from your main project and attach it there (with `.idea` directory inside) and I'll try to reproduce it with the same environment.
> What's the path `/tmp/36315c4c-bcd8-47f0-afa3-be8b81cd6de3/go/src#`, when i enter the terminal of container? i found dlv is working when run `/tmp/36315c4c-bcd8-47f0-afa3-be8b81cd6de3/go/bin/dlv`
It's a generated path by GoLand and you can change it via run target settings: https://www.jetbrains.com/help/go/run-targets.html#docker (Additional Settings | Project sources directory and Compiled executables directory).
Best Regards,
Daniil Maslov
JetBrains
I cannot reproduce the issue if I specify --workdir option and run it with run targets or by creating a new Docker configuration.
Can you remove --workdir option to see that the error will be different? Can you reproduce it with a popular default image e.g. debian?
Best Regards,
Daniil Maslov
JetBrains
I'm still investigating this case and trying to reproduce iton my own.
Meanwhile, have you tried remote debugging? You can run your own container and attach the debugger to it: https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#attach-to-a-process-in-the-docker-container
Will it work in that case?
Best Regards,
Daniil Maslov
JetBrains
We'll investigate the case with Run Targets and let you know the updates or post a link to our bug tracker.
Best Regards,
Daniil Maslov
JetBrains