Skip to content

duplicate-stage-name

Dockerfilecorrectnessno fixdefault: errordockerfile/hadolint

Reports a stage name that an earlier stage already uses, as in FROM a AS app followed by FROM b AS app. Names are compared without regard to case, as Docker does.

FROM name and COPY --from=name refer to a stage by its name. With two stages of one name the builder cannot tell which one is meant, so Docker rejects the file.

Reported
...
FROM alpine:3 AS build
FROM build
FROM scratch
FROM alpine:3 AS build
FROM $BASE
FROM alpine:3 AS Build
FROM BUILD
...
FROM localhost:5000/img:1
...
dockerfile:
lint:
rules:
duplicate-stage-name: error # off, warn, error (default)

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line duplicate-stage-name 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 DL3024 full