Skip to content

from-first

Dockerfilecorrectnessno fixdefault: errordockerfile/hadolint

Reports an instruction other than ARG before the first FROM. Comments, parser directives and blank lines are allowed there.

Every instruction works on a build stage, and a stage starts with FROM. Only ARG may come first, because its value can be used in the FROM line (ARG VERSION=3 then FROM alpine:${VERSION}). Any other instruction first makes the Dockerfile invalid, and Docker rejects it.

Reported
ARG V=1
RUN echo hi
FROM alpine:3
RUN echo ok
dockerfile:
lint:
rules:
from-first: error # off, warn, error (default)

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line from-first in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL3061 full