from-first
What it does
Section titled “What it does”Reports an instruction other than ARG before the first FROM. Comments, parser directives and blank lines are allowed there.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”ARG V=1RUN echo hiFROM alpine:3RUN echo okConfiguration
Section titled “Configuration”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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| hadolint | DL3061 |
full |