hadolint/DL4005¶
Use SHELL to change the default shell.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | Best Practice |
| Default | Enabled |
| Auto-fix | Yes (--fix) |
Description¶
Docker provides a SHELL instruction which does not require overwriting /bin/sh in your container. Instead of using ln -sf to redirect /bin/sh,
use the SHELL instruction to set the desired shell.
Examples¶
Problematic code¶
Correct code¶
Auto-fix¶
Replaces ln -sf targeting /bin/sh with a SHELL instruction. If the ln command is part of a larger RUN, the ln portion is removed and a
SHELL instruction is inserted after.
# Before
RUN ln -sf /bin/bash /bin/sh && apk add curl
# After (with --fix)
RUN apk add curl
SHELL ["/bin/bash", "-c"]