I'm running a Node application in Docker, with docker-compose. I'm using Traefik as a proxy.
I would like to be able to debug it in VS Code but I don't manage to connect to my app:
connect ECONNREFUSED 127.0.0.1:9229
Here are my files:
docker-compose.yml:
version: '3'
services:
traefik:
image: traefik:1.7
command: --docker --docker.exposedbydefault=false
ports:
- '80:80'
- 9229:9229
volumes:
- /var/run/docker.sock:/var/run/docker.sock
core:
image: node:alpine
labels:
- traefik.enable=true
- traefik.port=4001
- traefik.backend=core
- traefik.frontend.rule=Host:core.localhost
volumes:
- ./leav_core:/app
working_dir: /app
command: [sh, -c, 'npm start']
expose:
- '9229'
volumes:
arango_data:
driver: local
The command actually executed by npm start is:
ts-node --inspect=0.0.0.0:9229 --type-check src/`
The debug settings in VSCode:
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Attach to Node",
"type": "node",
"request": "attach",
"remoteRoot": "/app"
}
]
}
I access to my application with the URL defined on Traefik http://core.localhost but I don't know how to attach the debugger to it
Thanks!
exposeinside the docker-compose file should be declare like that ? docs.docker.com/compose/compose-file/#expose80:80,9229:9229but this is used for the expose as the left port is the exposed port and the right port is the port you wan't your redirection to point. You should try to use only ports:9229:YourAppPortand removeexpose