Public | Automated Build

Last pushed: a year ago
Short Description
The base is without npm.
Full Description

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

Versions v6.9.1, v4.6.1, v0.12.17 and v0.10.48 –
built on Alpine Linux.

NB: All images were recently updated to Alpine 3.4
there shouldn't be any breaking changes unless you rely on other apk packages. php has been
renamed to php5, cron to crond and most ruby- pkgs have been removed in favor of gem

All versions use the one mhart/alpine-node repository,
but each version aligns with the following tags (ie, mhart/alpine-node:<tag>). The sizes are for the
unpacked images as reported by Docker – compressed sizes are about 1/3 of these:

  • Full install built with npm:
    • latest, 6, 6.9, 6.9.1 – 49.73 MB (npm 3.10.8)
    • 4, 4.6, 4.6.1 – 36.14 MB (npm 2.15.11)
    • 0.12, 0.12.17 – 32.71 MB (npm 2.15.11)
    • 0.10, 0.10.48 – 28.16 MB (npm 2.15.11)
  • Base install with node built as a static binary with no npm:
    • base, base-6, base-6.9, base-6.9.1 – 38.17 MB
    • base-4, base-4.6, base-4.6.1 – 27.2 MB
    • base-0.12, base-0.12.17 – 24.07 MB
    • base-0.10, base-0.10.48 – 18.22 MB

Major io.js versions are tagged too.


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

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

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

$ docker run mhart/alpine-node:base node --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-4
# FROM mhart/alpine-node

ADD . .

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

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

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


As Alpine Linux uses musl, you may run into some issues with environments
expecting glibc-like behavior – especially if you try to use binaries compiled
with glibc. You should recompile these binaries to use musl (compiling on
Alpine is probably the easiest way to do this).

Inspired by:

Docker Pull Command
Source Repository

Comments (0)