docker / docs

Source repo for Docker's Documentation
https://docs.docker.com
Apache License 2.0
4.16k stars 7.25k forks source link

Debugging not working like in docs #17591

Closed ruud00000 closed 1 year ago

ruud00000 commented 1 year ago

Is this a docs issue?

Type of issue

Information is incorrect

Description

In nodejs->use containers for development section Use Compose to develop locally, when I run

docker compose -f docker-compose.dev.yml up --build

I get output as in nochromedebug.txt

So a bunch of messages after Debugger listening on ws://0.0.0.0:9229/2b7d2f1a-8c74-401f-a800-e42ededc314d, unlike the screenshot in the docs.

Then curl --request GET --url http://localhost:8000/notes seems to work fine. Result:

{"code":"success","meta":{"total":0,"count":0},"payload":[]}

Now shown in the terminal: getnotes.txt

Then when opening Chrome devtools with about:inspect nothing is showing under Remote Target, unlike in the docs and when I then click on 'Open dedicated DevTools for Node' I get a screen with no reference whatsoever to the server.js file, so nothing to debug.

Furthermore when I change something in server.js, unlike in the docs, nothing gets updated, nodemon doesn't restart, nothing logged in the terminal.

Is there something missing in the docs then or is there an issue I could solve?

Chrome version: 114.0.5735.134 (Officiële build) (64-bits) Running on Windows 11 Home 22H2 build 22621.1848 Running terminal in Visual Studio Code that shows this info:

Version: 1.79.2 (user setup)
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-14T08:57:04.379Z
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621

Package.json:

{
  "name": "docker",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "debug": "nodemon --inspect=0.0.0.0:9229 server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "curl": "^0.1.4",
    "nodemon": "^2.0.22",
    "ronin-database": "^0.1.1",
    "ronin-mocks": "^0.1.11",
    "ronin-server": "^0.1.3"
  }
}

Dockerfile:

# syntax=docker/dockerfile:1

FROM node:18-alpine

ENV NODE_ENV=production

WORKDIR /app

COPY ["package.json", "package-lock.json*", "./"]

RUN npm install --production

COPY . .

CMD ["node", "server.js"]

Location

https://docs.docker.com/language/nodejs/develop/

Suggestion

Please advise what to do in order to be able to follow the instructions in the docs (and update docs if there is something missing in the docs).

craig-osterhout commented 1 year ago

Thanks for sharing the issue.

In regards to nodemon not detecting changes, try this: In the package.json file, update the debug script line to include the -L option. debug": "nodemon --inspect=0.0.0.0:9229 -L server.js"

In regards to Chrome DevTools not showing a Remote Target, click on Configure next to Discover network targets, and then add 127.0.0.1:9229 image

docker-robot[bot] commented 1 year ago

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked