Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Debug nodejs app inside Docker container

I've been setting up a Nodejs project using Docker for the first time and I'm having trouble attaching a debugger to the app.

here's my docker files:

FROM node:latest
LABEL Name=graphql Version=0.1.0 

# Create app directory
RUN mkdir -p /graphql
WORKDIR /graphql

# Install app dependencies
COPY package.json /graphql
RUN npm install -g gulp
RUN npm install

# Bundle app source
COPY . /graphql

EXPOSE 3000
EXPOSE 5858
EXPOSE 8000

CMD gulp

and the compose one:

version: '2'

services:
  graphql:
    image: graphql:latest
    container_name: apollo-graphql
    build:
      context: .
      dockerfile: dockerfile
    environment:
      NODE_ENV: development
    tty: true
    ports:
      - 3000:3000
      - 5858:5858
      - 8000:8000
    volumes:
      - .:/graphql
    ## set your startup file here
    command: gulp

the gulp task is currently launching nodemon like this:

gulp.task('serve', ['bundle'], () => {

    stream = nodemon({
        execMap: {
            js: 'node --debug=5858'
        },
        script: 'build/server.bundle.js',
        verbose: true
    })

This seems to run everything just fine, including an output stating: Debugger listening on 127.0.0.1:5858 However I can't seems to connect to it. I'm using VScode and my launch config file is the following:

"name": "Attach",
"type": "node",
"request": "attach",
"address": "127.0.0.1",
"port": 5858,
"localRoot": "${workspaceRoot}/graphql/",
"remoteRoot": "/graphql/",

Even if I change the --debug flag to --inspect to use the new protocol, I still can't open it in Chrome devtools.

I've seen some tutorials and those pretty much do what I'm doing here but am I missing something here? I have also seen some suggestions on StackOverflow about running a second container with node-inspect, but I'd rather not go that route as I'm trying to keep things simple. In fact, this sort of setup seems to work in those tutorials, so why doesn't it work for me?

Thanks in advance!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I've verified this configuration several times and can't reproduce the problem

here is my entire .vscode/launch.json file

{
    // Use IntelliSense to learn about possible Node.js debug attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Docker container",
            "port": 5858,
            "address": "127.0.0.1",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "/var/app"
        }
    ]
}

the only thing i can think of is to make sure you are running the "Attach" debug mode in VS Code.

otherwise, I'm clueless. it seems to be working for me.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!