require-dockerfile-first-instruction-from
Require the first non-comment Dockerfile instruction to be FROM.
Targeted pattern scopeâ
- Repository-root Dockerfile instruction order.
What this rule reportsâ
This rule reports Dockerfiles where a meaningful instruction appears before
FROM.
Why this rule existsâ
Dockerfile semantics require a base image stage; ensuring FROM appears first
keeps files valid and predictable.
â Incorrectâ
WORKDIR /app
FROM node:22-alpine
â Correctâ
# syntax=docker/dockerfile:1
FROM node:22-alpine
WORKDIR /app
When not to use itâ
Disable this rule only if Dockerfiles are generated and guaranteed valid by another controlled step.
Rule catalog ID: R112