pipefail-shell
What it does
Section titled “What it does”Reports a RUN with a pipe (a | b) in a stage whose SHELL does not set pipefail. No earlier SHELL instruction of the stage has a word that contains pipefail (SHELL ["/bin/bash", "-o", "pipefail", "-c"]). A set -o pipefail inside the RUN itself does not count. A new FROM starts the check again.
Why it matters
Section titled “Why it matters”The exit status of a pipe is the one of its last command. curl -f https://example.com/x | tar xz succeeds even when curl fails and tar gets nothing, so the build goes on with a missing or broken file and the error shows up much later. With pipefail any failing command of the pipe fails the RUN.
To fix, set the option for the stage with SHELL ["/bin/bash", "-o", "pipefail", "-c"]; the default /bin/sh of some images (Debian’s dash) does not have the option.
Example
Section titled “Example”...
RUN a | bRUN a || bRUN ["a", "b"]SHELL ["/bin/bash", "-o", "pipefail", "-c"]RUN a | bFROM debian:12RUN a | b...Configuration
Section titled “Configuration”dockerfile: lint: rules: pipefail-shell: warn # off, warn (default), errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line pipefail-shell in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| hadolint | DL4006 |
partial | A SHELL instruction with a word that contains pipefail ends the check for the rest of the stage. |