Repaso
EspaƱol
Cloud & DevOpsIntermediateOPS-03

Why use a multi-stage Docker build?

Options

  1. To run several containers at once from a single Dockerfile
  2. To compile in one stage and copy only the artifacts into a small image (Correct option)
  3. To build for several CPU architectures automatically in one step
  4. To avoid writing a Dockerfile by reusing the one from another image

Answer

To build/compile in one stage and copy only the artifacts into a small runtime image

Why

Building often needs heavy tools (compilers, build dependencies, Node to bundle a frontend) that the running app does not need.

A multi-stage build uses a first 'builder' stage with all tools, then a second, slim stage that copies only the finished result.

The final image is smaller, downloads faster and has fewer things an attacker could exploit.

Remember

Multi-stage = build big, ship small.

Key terms

Practice this question in Repaso