ScanSkill

FROM

It initializes a new build stage and sets the base image for subsequent instructions. To be valid a Dockerfile, it must start with FROM instruction.

Syntax

FROM [--platform-<platform>] <image> [AS <name>]

OR

FROM [--platform-<platform>] <image>[:<tag>] [AS <name>]

OR

FROM [--platform-<platform>] <image>[@<digest>] [AS <name>]

Note: ARG is the one and only instruction that precedes FROM in Dockerfile.

Example

ARG VERSION=latest
FROM busybox:$VERSION
ARG VERSION
RUN echo $VERSION

Here, ARG declared before FROM is outside of a build stage, so it can’t be used after FROM instruction. To use later, you need to re-declare as above.