provegard / ncdbg

A debugger for Nashorn that uses Chrome DevTools as frontend
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

cannot access devtools url from docker container #104

Closed hugsyy closed 5 years ago

hugsyy commented 5 years ago

Hello, I am running ncdbg in a docker container. It connects to a spring boot app running in another container. But I cannot access chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:7778/dbg. Screenshot_ws

This is my Dockerfile for ncdbg:

FROM openjdk:8-jdk-alpine
RUN apk add --update bash && rm -rf /var/cache/apk/*
COPY /bin/ncdbg /bin/ncdbg
COPY /bin/ncdbg.bat /bin/ncdbg.bat
COPY /lib /lib
COPY docker-entrypoint.sh docker-entrypoint.sh
EXPOSE 7778
CMD ["sh","docker-entrypoint.sh"]

And this is docker-entrypoint.sh:

#!/bin/sh
./bin/ncdbg --connect bug:7777

I ran ncdbg container by mapping ports -p 7778:7778 so 7778 is exposed on host machine. Here's the log:

NCDbg version: 0.8.3
NCDbg built with Java version: 1.8
Local Java version: 1.8.0_212
Connecting to bug:7777...
Connected!
Remote VM information:
Java Debug Interface (Reference Implementation) version 1.8 
Java Debug Wire Protocol (Reference Implementation) version 1.8
JVM Debug Interface version 1.2
JVM version 1.8.0_212 (OpenJDK 64-Bit Server VM, mixed mode, sharing)
Enabling breaking on exceptions in script classes.
Server is listening on localhost:7778
Open this URL in Chrome: chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:7778/dbg
Receiving WebSocket clients at localhost/127.0.0.1:7778
Class scanning complete! Scanned 10668 classes in total.
Enabling automatic breaking at JavaScript 'debugger' statements
Host initialization is complete.
provegard commented 5 years ago

Can you try setting the listening address (see https://github.com/provegard/ncdbg/tree/master/docs#setting-the-listening-address) to something like 0.0.0.0:7778?

Possibly also change the "localhost" part of the devtools URL.

hugsyy commented 5 years ago

It worked! Thank you very much! I configured it to listen 0.0.0.0:7778 but apparently it must remain localhost in devtools URL. Changing localhost in URL to 0.0.0.0 didn't work,

provegard commented 5 years ago

Glad to hear you got it working! :-)