NOTICE:
Active maintenance of the image has been halted. Your contributions are welcome.
Dockerfile to build a nodejs+express image with nodemon.
If you find this image useful here's how you can help:
docker run -it --rm -v /usr/local/bin:/target \
sameersbn/nodejs:latest install
This installs wrapper scripts to launch node
, nodejs
, npm
, express
and nodemon
on the host.
Note: These commands are executed on the host
express -c less myExpress
cd myExpress
npm install
npm start
You can also use nodemon bin/www
instead of npm start
.
If the command being executed is present on the host, then the host command is executed and the docker image is not started.
The only known limitation is that you cannot install node modules globally, that is to say npm install -g <module-name>
will not work. These can only be installed from the Dockerfile
. If you want to add node modules globally please send a PR.
The wrapper scripts mount the current working directory and host networking while starting the sameersbn/nodejs
image. The command executed while starting the image is the same as the name of the wrapper script that was launched with whatever arguments were passed while running the wrapper script.
For example, if npm start
is executed, the following command is executed by the wrapper script:
docker run -it --rm --net=host \
-v $PWD:/home/nodejs/src sameersbn/nodejs:latest npm start
To upgrade to newer releases, simply update the image
docker pull sameersbn/nodejs:latest
docker run -it --rm -v /usr/local/bin:/target \
sameersbn/nodejs:latest uninstall