Public | Automated Build

Last pushed: 3 months ago
Short Description
Dockerfile for node.js with node_modules in container
Full Description

Baseimage for Node.js applications

$ docker build -t uwegerdes/nodejs .

Build with npm-proxy-cache on localhost-ip (accessed from docker internal network)

$ docker build -t uwegerdes/nodejs \
    --build-arg NPM_PROXY="http://$(hostname -i):3143" \
    --build-arg NPM_LOGLEVEL="warn" \

Replace the $(hostname -i) with your proxy address if it's not on localhost - or remove that line.

On loglevel warn you have to wait a while if a greater amount of packages have to be loaded, use info for much more output.


Use this baseimage in other Dockerfiles:

FROM uwegerdes/nodejs

Or start a container (in your node project directory) with:

$ docker run -it \
    --name nodejs \
    -v $(pwd):/home/node/app \
    uwegerdes/nodejs \

Restart it with:

$ docker start -ai nodejs

Inside the container you can use npm init in the app directory.

If you want to install node modules in the container and not your working directory please use the following commands:

$ cd ${HOME} && \
    cp ${APP_HOME}/package.json . && \
    npm install --save-dev node_module && \
    cp package.json ${APP_HOME}/ && \
    cd ${APP_HOME}


The user node with password node and home directory /home/node is created.

The following variables are set:

  • USER_NAME=node
  • HOME=/home/node
  • NODE_HOME=/home/node
  • NODE_PATH=/home/node/node_modules:/usr/lib/node_modules
  • NODE_ENV=development
  • APP_HOME=/home/node/app

Optional parameter from build command:

Docker Pull Command
Source Repository