You, Node.js Development, and Docker

Get running.

Make sure node_modules is different from your host’s

Apply the “node_modules volume trick” so you can separate the node_modules install on your host from the Docker container’s.

If you’re using docker-compose.yml, edit your Node.js app’s volumes to include this line:

  - /app/chat/node_modules

Make sure your Docker containers are running and start sh inside your app’s Docker to make sure the node_modules exists and is different from your host’s.

$ docker-compose up
$ docker-compose exec nodejs_docker-app_service_name sh
docker$ ls node_modules

Connect to your Node.js app

Use docker container ls to get the Docker container’s name, if necessary.

$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nodejs_docker_app-docker_name


Clone my fork of nodejs-api-starter to see finished changes, and some other additions.