microsoft / vscode-js-debug

A DAP-compatible JavaScript debugger. Used in VS Code, VS, + more
MIT License
1.67k stars 283 forks source link

It doesn't attach to processes in docker containers running under root (Attach to process: cannot enable debug mode for process '...' (Error: kill EPERM)) #2042

Closed x-yuri closed 4 months ago

x-yuri commented 4 months ago

Describe the bug See the title.

To Reproduce Steps to reproduce the behavior:

a.js:

debugger
$ docker run --rm -itv "$PWD/a.js:/a.js" -p 9229:9229 alpine:3.20 \
    sh -euxc 'apk add nodejs && node --inspect-brk=0.0.0.0 a.js'

$ code --disable-extensions

With the following command it works (I assume here that you're running under UID 1000):

$ docker run --rm -itv "$PWD/a.js:/a.js" -p 9229:9229 alpine:3.20 \
    sh -euxc 'apk add nodejs shadow && useradd a \
        && su a -c "node --inspect-brk=0.0.0.0 a.js"'

This happens because the target process is unconditionally sent SIGUSR1, although the process might already be in debug mode.

Log File

VS Code Version: 1.91.0

Additional context It was supposedly fixed, but it's not.