

Lesson 07 · 11 min
A smaller, safer image
Multi-stage builds, .dockerignore, and a non-root user.
11 minLesson 7 of 9Practice includedAsk AI on any point
The build needs the TypeScript compiler, dev dependencies, and source code, while running needs only the result. A multi-stage Dockerfile has several FROMs: the first stage builds, the second copies only what's needed from it (COPY --from=build). The image becomes several times smaller, downloads faster, and contains less that can be attacked.
Sign in to continue
The rest of this lesson opens after sign up
The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.