Public | Automated Build

Last pushed: 2 years ago
Short Description
Alpine Image that works with Kubernetes and other platforms that use DNS for service discovery.
Full Description

Minimal Node.js Docker Images (18MB, or 6.6MB compressed)

Versions v5.3.0, v4.2.4, v0.12.9, v0.10.41, and io.js – built on Alpine Linux.

All versions use the one mhart/alpine-node repository,
but each version aligns with the following tags (ie, mhart/alpine-node:<tag>):

  • Full install built with npm (2.14.15 unless specified):
    • latest, 5, 5.3, 5.3.0 – 36.55 MB (npm 3.5.2)
    • 4, 4.2, 4.2.4 – 36.38 MB
    • 0.12, 0.12.9 – 32.08 MB
    • 0.10, 0.10.41 – 27.44 MB
  • Base install with node built as a static binary with no npm:
    • base, base-5, base-5.3, base-5.3.0 – 26.01 MB
    • base-4, base-4.2, base-4.2.4 – 25.6 MB
    • base-0.12, base-0.12.9 – 22.3 MB
    • base-0.10, base-0.10.41 – 18.5 MB

Major io.js versions are tagged too.


$ docker run mhart/alpine-node node --version

$ docker run mhart/alpine-node:4 node --version

$ docker run mhart/alpine-node npm --version

$ docker run mhart/alpine-node:base node --version

$ docker run mhart/alpine-node:3 iojs --version

$ docker run mhart/alpine-node:base-0.10 node --version

Example Dockerfile for your own Node.js project

If you don't have any native dependencies, ie only depend on pure-JS npm
modules, then my suggestion is to run npm install locally before running
docker build (and make sure node_modules isn't in your .dockerignore) –
then you don't need an npm install step in your Dockerfile and you don't need
npm installed in your Docker image – so you can use one of the smaller
base* images.

FROM mhart/alpine-node:base
# FROM mhart/alpine-node:base-0.10
# FROM mhart/alpine-node

ADD . .

# If you have native dependencies, you'll need extra tools
# RUN apk add --update make gcc g++ python

# If you need npm, don't use a base tag
# RUN npm install

# If you had native dependencies you can now remove build tools
# RUN apk del make gcc g++ python && \
#   rm -rf /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp

CMD ["node", "index.js"]


As Alpine Linux uses musl, you may run into some issues with environments
expecting glibc-like behaviour (for example, Kubernetes). Some of these issues
are documented here:

Inspired by:

Docker Pull Command
Source Repository

Comments (0)