Create lean Node.js image with Docker multi-stage build

Click for: original source

Alexei Ledenev’s blog post about single Dockerfile that can build multiple helper images with compilers, tools, and tests and use files from above images to produce the final Docker image.

Article depicts basic idea behind the Docker build container pattern. A Dockerfile is a text file that contains a list of all the commands needed to build a new Docker image. The syntax of Dockerfile is pretty simple and the Docker team tries to keep it intact between Docker engine releases. The core principle is very simple: 1 Dockerfile -> 1 Docker Image. This principle works just fine for basic use cases.

Article then describes changes introduced in Docker 17.0.5 which extends Dockerfile syntax to support new multi-stage build, by extending two commands: FROM and COPY.

Example Dockerfile for multi-stage Node.js app with explanation is included. With Docker multi-stage build feature, it’s possible to implement an advanced Docker image build pipeline using a single Dockerfile.

[Read More]

Tags docker containers