Debug with VScode and NodeJs app on docker image

Sebastian Velez Zuluaga
3 min readJul 15, 2022

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.

app.js

note: If you try to run this code on your mac change your host 0.0.0.0 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

http://localhost:3000

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

launch.json

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 :

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response