| Property | Value |
|---|---|
| Severity | Info |
| Category | Reliability |
| Default | Enabled |
| Auto-fix | Yes (--fix --fix-unsafe) |
Description
Detects Dockerfile stages that usewget without a retry configuration file. This applies
both when wget is invoked directly in a RUN command and when the stage installs the
wget package first. Transient download failures are common during image builds, so a small
wgetrc file makes those stages more resilient.
The rule emits at most one violation per stage and triggers when:
- A
RUNinstruction invokeswgetdirectly (for examplewget https://...) - A
RUNinstruction installs thewgetpackage (for exampleapt-get install -y wget) - On Windows:
wget.exeinvocation or package installs that resolve towget
Auto-fix
The fix inserts a short documentation comment plus two instructions before the first relevantRUN:
- Install trigger (
apt-get install wget): inserts right before the installRUN - Invocation trigger (
wget https://...): inserts before the firstRUNin the stage whenwgetis already available from the base image
Linux
Windows
--chmod is omitted since it has no effect.
Config options
retry_connrefused = onretries connection-refused failurestimeoutlimits how long each request can wait (default: 15 seconds)triescontrols how many attempts wget makes (default: 5)
Configuration
The emitted defaults can be overridden via rule config:Wgetrc Commands.
Examples
Before (violation)
After (fixed with —fix —fix-unsafe)
Suppression
The rule does not trigger when:- The config file
/etc/wgetrc,c:\wgetrc, or a user-level.wgetrcalready exists in the stage (viaCOPYheredoc,COPYfrom build context,COPY --fromanother stage, orRUNfile creation) - The
WGETRCenvironment variable is already set in the stage
Related rules
hadolint/DL3047checkswgetcommand progress outputtally/prefer-add-unpackrewriteswgetdownload-and-extract patterns toADD --unpacktally/prefer-copy-heredocdetects file creation viaRUNand suggestsCOPYheredoc instead