FROM
What is FROM?
FROM: Sets the base image for the build stage. Must be the first instruction (after optional ARGs). Can appear multiple times in a multi-stage build. FROM is the first instruction in a Dockerfile. It sets the base image the build starts from, such as FROM php:8.4-fpm-alpine or FROM node:22-slim. A Dockerfile can contain several FROM lines. Each starts a new stage in a multi-stage build. You might compile assets in a Node stage, install PHP dependencies in a Composer stage, and copy only the finished results into a small final image.
Frequently asked questions about FROM
What should you keep in mind with FROM?
Multi-stage builds keep production images small and free of build tools, which makes them faster to deploy and gives attackers less to work with. Name your stages with AS, as in FROM node:22 AS assets, so later COPY --from=assets lines are readable. Pin base image versions so builds are repeatable.
What does an example of FROM look like?
FROM python:3.12-slim AS base At a glance
| Category | Docker |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |