| Property | Value |
|---|---|
| Severity | Warning |
| Category | Correctness |
| Default | Enabled |
Description
Detects shell-formRUN instructions (e.g., RUN echo "hello") in FROM scratch stages.
Shell-form RUN requires a shell (/bin/sh by default) in the container’s root filesystem.
Since scratch is an empty image with no shell, these instructions will always fail at build time.
If you explicitly set a SHELL instruction in the scratch stage, this rule is suppressed because
it assumes you have bootstrapped a shell binary into the stage (e.g., via COPY --from or ADD).
Common causes:
- Changing
FROM alpinetoFROM scratchto shrink the image without reworkingRUNinstructions - An AI patch replacing the base image without adjusting command forms
Examples
Bad
Good (exec-form)
Good (explicit SHELL after bootstrapping)
Good (different base image)
Related rules
tally/copy-from-empty-scratch-stage— if a scratch stage contains only a shell-formRUN, this rule fires butcopy-from-empty-scratch-stagedoes not (because anyRUNcounts as file-producing). If you remove the failingRUNin response to this warning, the stage becomes truly empty andcopy-from-empty-scratch-stagewill then fire on any downstreamCOPY --from.