Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot attach debugger to Docker Node 8.9.x #589

Closed
tpuza opened this issue Nov 20, 2017 · 7 comments
Closed

Cannot attach debugger to Docker Node 8.9.x #589

tpuza opened this issue Nov 20, 2017 · 7 comments
Labels

Comments

@tpuza
Copy link

tpuza commented Nov 20, 2017

We run and debug NodeJS apps at Docker containers (6.12.0) using VSCode or Chrome DevTools (chrome://inspect) without any problems.

Attaching debugger to NodeJS containers based on new LTS version 8.9.x stoped to work (debugger attach timeouts). Both VSCode and Chrome DevTools attach behave the same.

Same behavior is reproducible on both Windows 10 an MacOS (High Siera), latest Docker installation.

Dockerfile looks like this

FROM node:8.9.1-slim
ENV PORT=8080

RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY ./ /usr/src/app

RUN npm i

CMD ["node", "--inspect", "bin/www"]

Command used to run container (exposing debugging 9229 and web server 8080 ports)

docker run --rm -p 9229:9229 -p 8080:8080 --name docker_debug docker_debug
Demo app is simple NodeJS express app bootstraped using express-generator tool.

VSCode Launch configuration to attach running Docker app looks like this

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Docker: Attach to Node",
      "type": "node",
      "request": "attach",
      "port": 9229,
      "address": "localhost",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/usr/src/app",
      "protocol": "inspector"
    }
  ]
}

As mentioned, debugger attach works without any problems when switching base image to former Node LTS version 6.12.0.

FROM node:6.10.0-slim

I have tested 8.9.0, 8.9.1, slim and alpine base images with same result.

@chorrell
Copy link
Contributor

chorrell commented Nov 20, 2017

Is this reproducible with just Node.js v8.9.1 without docker?

@tpuza
Copy link
Author

tpuza commented Nov 20, 2017

@chorrell No, it is only docker / debug in docker container issue.

@SimenB
Copy link
Member

SimenB commented Nov 20, 2017

It works for me if the CMD is --inspect=0.0.0.0 instead of just inspect. Not really sure why

@tpuza
Copy link
Author

tpuza commented Nov 20, 2017

Yes, I confirm, that @SimenB 's solution works for me too. Thank you.
Even though this is solution to the issue, it is different behaviour to the v6.12.0 and it would be nice to know why is it so.

@SimenB
Copy link
Member

SimenB commented Nov 20, 2017

Probably related to nodejs/node#11591 (comment)

Closing, as I don't think this is actionable for us. Feel free to keep discussing, though 🙂

@SimenB SimenB closed this as completed Nov 20, 2017
@tecfu
Copy link

tecfu commented Jul 25, 2018

@SimenB This is a pretty time consuming gotcha that I haven't found documented anywhere other than this issue.

Is there any reason why we can't at least put something about this in the README.md?

@SimenB
Copy link
Member

SimenB commented Jul 26, 2018

PR most welcome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants