| Property | Value |
|---|---|
| Severity | Info |
| Category | Reliability |
| Default | Enabled |
| Auto-fix | Yes (--fix --fix-unsafe) |
Description
Detects Dockerfile stages that usecurl (either invoked directly in a RUN command or
installed as a package) without a retry configuration file. Transient download failures are
common during image builds — network timeouts, temporary server errors, and DNS hiccups can
cause builds to fail unpredictably. A small .curlrc file with retry settings makes builds
significantly more robust.
The rule emits at most one violation per stage and triggers when:
- A
RUNinstruction invokescurldirectly (e.g.,curl -fsSL https://...) - A
RUNinstruction installs thecurlpackage (e.g.,apt-get install -y curl) - On Windows:
curl.exeinvocation orchoco install curl/winget install curl
Auto-fix
The fix inserts a short documentation comment plus two instructions before the first relevantRUN:
- Install trigger (
apt-get install curl): inserts right before the installRUN - Invocation trigger (
curl https://...): inserts before the firstRUNin the stage (curl is already available from the base image)
Linux
Windows
--chmod is omitted since it has no effect.
Config options
--retry-connrefusedretries on connection-refused errors--connect-timeoutlimits the connection phase (default: 15 seconds)--retryretries failed transfers (default: 5)--max-timelimits the entire transfer (default: 300 seconds)
Configuration
The emitted defaults can be overridden via rule config:--config.
Examples
Before (violation)
After (fixed with —fix —fix-unsafe)
Suppression
The rule does not trigger when:- The config file
/etc/curl/.curlrc(orc:\curl\.curlrcon Windows) already exists in the stage (viaCOPYheredoc,COPYfrom build context,COPY --fromanother stage, orRUNfile creation) - The
CURL_HOMEenvironment variable is already set in the stage
Related rules
tally/curl-should-follow-redirects— ensures curl uses--locationto follow HTTP redirectstally/prefer-copy-heredoc— detects file creation viaRUNand suggestsCOPYheredoc instead