utahlmka.blogg.se

Attaching visual studio code debugger to docker node.js
Attaching visual studio code debugger to docker node.js











attaching visual studio code debugger to docker node.js

It’ll hit the breakpoint every time the browser refreshes, which is every 2 seconds. Hit the Play button at the top to resume code execution. If not, go back and refresh it – VSCode will pop back to the front as soon as the debugger hits it. If your browser window is still open and refreshing, in a second or two you should see it hit the breakpoint. Set a breakpoint by clicking in the gutter, just to the left of the line number. Now go back to app.js and find the line that reads lineIndex += 1 line, just after we initialize the message variable. With the “Attach” config selected, click the “play” button to start the debugger.

attaching visual studio code debugger to docker node.js

remoteRoot is set to the path of the code directory inside the container, because it’s almost certainly different than the path to the code on your machine.restart is set to true, so that the debugger re-attaches when the app restarts.The whole “Launch” config has been deleted – you’re using Compose to launch the app, not VSCode, so it’s unnecessary.Using your terminal, navigate to the directory with the app files and start up the app: Finally, it maps port 5858 inside the container to the same port on localhost, so you can connect to the remote debugger.It maps port 8000 inside the container to port 8000 on localhost, so you can actually visit the application.

attaching visual studio code debugger to docker node.js

This is very useful, as it means you don’t have to rebuild the image every time you make a change to the application. This means that the code inside the running container will update whenever you update the local files on your hard drive. It overwrites the application code in the container by mounting the current directory as a volume.We do that here because when you ship this application’s container image to production, you don’t want the debugger enabled – it’s a development-only override. It overrides the command specified in the Dockerfile to enable the remote debugging feature built into Node.js.It defines a service called “web”, which uses the image built from the Dockerfile in the current directory.













Attaching visual studio code debugger to docker node.js