Command line
Expose Node Inspector and debug without VS Code
Node Inspector is the debugging interface built into Node.js. It allows a debugger to pause JavaScript execution, inspect variables, and control stepping. The application can be started with this interface enabled without rebuilding its image:
docker run --rm -d -p 127.0.0.1:<HOST_APP_PORT>:<CONTAINER_APP_PORT> -p 127.0.0.1:9229:9229 <IMAGE> node --inspect=0.0.0.0:9229 <ENTRYPOINT>A normal node <ENTRYPOINT> process has no inspector endpoint. --inspect=0.0.0.0:9229 makes the inspector listen on every container network interface. The first -p maps the host application port to the container application port. The second maps host port 9229 to container port 9229, with 127.0.0.1 restricting access to the host loopback interface. -d runs the container in the background, and --rm removes its container record after it stops.
EXPOSE 9229 records intended port usage as image metadata. The -p 127.0.0.1:9229:9229 argument publishes the inspector port to the host.
The arguments after <IMAGE> replace the image’s configured startup command for this container. The original image remains unchanged, and no rebuild is required.
The node inspect command starts Node.js’s terminal debugger and connects it to the inspector endpoint:
node inspect 127.0.0.1:9229cont resume execution until another breakpoint or debugger statement
next execute the current line without entering a called function
step enter the function called by the current line
out finish the current function and return to its caller
repl open a prompt that evaluates expressions in the selected paused scopeFind by: command line debugging, node inspector, node inspect, inspect 9229, docker run, expose port, publish port, no vscode, terminal debugger