COPY to a relative destination without WORKDIR set.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | Best Practice |
| Default | Enabled |
| Auto-fix | Yes (suggestion --fix-unsafe; safe with --slow-checks) |
Description
While copying to a relative path is not problematic per se, errors happen when changes are introduced to theWORKDIR without updating the
destination of the COPY command. It is assumed that when a WORKDIR is set, the programmer will make sure it works well together with the COPY
destinations.
Examples
Problematic code
Correct code
Auto-fix
Inserts an explicitWORKDIR instruction before the first COPY with a relative destination.
- Fast path (no registry access): suggests
WORKDIR /appas a conventional default (FixSuggestion, requires--fix-unsafe). - With
--slow-checks: resolves the base image’s actualWORKDIRfrom the registry and uses that value (FixSafe, applied with--fix).