Running your Node App on Docker

If you’re a code-hipster you create your new apps using Node and of course deploy using Docker ;). This article shows a quick way how.

What base image should we use? Most obvious are the official node image and Google’s google/nodejs image.

Looking at their sizes we go for the last one.

REPOSITORY         TAG             IMAGE ID          VIRTUAL SIZE
node               0.10-onbuild    237c2a0fc3f9      630.8 MB
google/nodejs      latest          e5e42af565ae      324 MB

Create a .dockerignore file. Add stuff like:


Create a Dockerfile:

FROM google/nodejs-runtime

ENV NODE_ENV=production

# Assets
RUN ./node_modules/bower/bin/bower install --allow-root
RUN ./node_modules/.bin/connect-assets -i bower_components -o public/assets


Create a docker-compose.yml:

  build: .
    - "80:8080"

Now build your environment using docker-compose build and start it using docker-compose up.

Next you should be able to access your app via boot2docker typically on Check boot2docker ip for your actual IP.