hadolint/DL3027¶
Do not use apt as it is meant to be an end-user tool, use apt-get or apt-cache instead.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | Best Practice |
| Default | Enabled |
| Auto-fix | Yes (--fix) |
Description¶
apt is discouraged by the Linux distributions as an unattended tool as its interface may change between versions. Use the more stable apt-get and
apt-cache commands in Dockerfiles instead.
Examples¶
Problematic code¶
Correct code¶
Auto-fix¶
Replaces apt with apt-get or apt-cache depending on the subcommand.
- Safe fix (
FixSafe):install,remove,update,upgrade,autoremove,purge,clean,autocleanare replaced withapt-get - Suggestion fix (
FixSuggestion):search,show,policyare replaced withapt-cache
# Before
RUN apt install -y curl && apt search python
# After (with --fix)
RUN apt-get install -y curl && apt-cache search python