Use Docker to Create a Node Development Environment

Leverage Docker images and containers to create an isolated Node development environment that runs a server.

Read on >>

1 Like

So this doesn’t work for me when I use docker-compose run, but does work when I use docker run. When using docker-compose I always get “Site can’t be reached”.

You have to use “–service-ports” with “docker-compose run …” Otherwise, the ports aren’t exposed and mapped. This post should be edited to reflect that fact.


Yep that fixed it. Thanks!

Great catch! That was on oversight on my part. Thank you for helping out @unclejustin :grinning: I was out sick these past days.
I will be updating the post right away :slight_smile:

Do you have any developers using Windows? Concurrent file access with host mounted volumes appears to be a problem experienced in Docker for Windows:

1 Like

@jzamor Thank you for bringing up this concern! I am currently in the process of researching Docker in a Windows environment and also Windows Containers. I am waiting for a few resources to line up to be able to provision a native Windows OS :pray: Please stay tuned and thank you for reading :muscle:

When I run the container we docker-compose it keeps restarting. when I run docker logs node (name of container) there is no logs. Not sure what I am doing wrong here can you help please?
Everything work perfect with the dockerrun command
docker run --rm -it --name node-docker
-v $PWD:/home/app -w /home/app
-e “PORT=3000” -p 8080:3000
-u node node:latest /bin/bash

Dockerfile in node folder
FROM node:latest
WORKDIR /home/app
USER node
ENTRYPOINT /bin/bash

version: ‘3.7’
build: node/
hostname: node
container_name: node
restart: always
- 9005:3000
- {USERDIR}/node:/home/app I have a .env file created for the {USERDIR} pointing to /srv/dev-disk-by-label-media/server/config/LEMP