Debug with VScode and NodeJs app on docker image

Develop enviroment.

Docker is a very interesting tecnology with some many uses, today I will show you how can create my setup enviroment on my Mac.

1. Intall nodeJS

2. Install Docker.

3. install visual Code.

4. Let create de initial project with express.

npm init

Very important note, be sure that in your packge.json are all dependencies.

This is my code.


note: If you try to run this code on your mac change your host by “localhost”. Just if you want to test your code is working.

6. Some things about docker, if you want you create a composer file is to create some images, if you want to create one image just needs the DockerFile.

This is my docker file is created in the same path that my project.

Good explanation of the docket blocks :

The structure from my project.

7. Open Docker on your PC.

On mac you check if docker is working.

docker -v

8. Lets create the image.

docker build -t docker-test .

9. Now luch the image.

docker run -p 3000:3000 -p 9229:9229 docker-test

Note: You can change the ports, but be sure that the ports that you expose mach whit the ports on the command.

Verify in your browser that the app is working


10. Start debug, create a configuration on visualcode to launch the debugger.


Check some thing after debug. You image is runnuig, the debug is link with your image and the debug console is showing your message.

Test adding some breakpoints in your app.

Lets code !

Happy Docker.

Helpfull video :



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store