Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jsainthilaire/debug-go-docker-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Docker image for Go debug

This image allows you to debug a go app just creating a volume pointing your app.

Usage

The recommended way is to set the session is using docker-compose.

  • create a volume mapping the /go/app directory to your project root one.
  • map the debugger port, by default is 2345, this can be change by setting the env variable DEBUG_ADDR
  • set the security_opt to seccomp:unconfined in order to run the container without the default secure computing mode.

note: while running in debug mode you need to connect the debugger client and your code will start running, you program execution will be blocked if you haven't connect your client.

Configure your editor/IDE

GoLand

  • go to run and select edit configuration and add a new go remote profile.

Screen Shot 2020-05-10 at 3 10 43 PM

  • set the port if you change it while mapping them, and just run the new configuration.

VS Code

  • create a launch.json file
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "attach",
            "mode": "remote",
            "remotePath": "/go/app",
            "port": 2345,
            "env": {},
            "args": [],
            "showLog": true,
            "trace": "verbose"
          }
    ]
}

port will be 2345 y default, but if you changed it in the mapping process of the container it needs to be set here.

  • go to Run/Start Debugging

About

Docker image to debug a docker app, this is not optimized and is using volumes to run the code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published