Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda