| Property | Value |
|---|---|
| Severity | Warning |
| Category | Best Practice |
| Default | Enabled |
| Auto-fix | Yes (--fix) |
Description
Only usecd in a subshell. Most commands can work with absolute paths. Docker provides the WORKDIR instruction if you really need to change the
current working directory.
When executed in a subshell, cd only affects the single RUN instruction, not any subsequent instructions. This can be an advantage over WORKDIR
which affects all subsequent instructions.
Examples
Problematic code
Correct code (with WORKDIR)
Correct code (with absolute paths)
Auto-fix
SplitsRUN with cd into WORKDIR + RUN instructions. Removes redundant mkdir commands before cd targets.