Linux Package Managers
debt(d5/e3/b3/t5)
Closest to 'specialist tool catches it' (d5). The detection_hints list hadolint, dive, and trivy — all specialist tools that catch Docker-specific package manager misuse (uncleaned caches, missing apt-get update, etc.). These are not default linters bundled with standard editors, and the issues are silent at runtime until image size or staleness becomes apparent.
Closest to 'simple parameterised fix' (e3). The quick_fix is a single appended command pattern (apt-get clean && rm -rf /var/lib/apt/lists/*) added to Dockerfile RUN instructions. While it's nearly a one-liner per occurrence, common_mistakes span several distinct patterns (apt update missing, no clean, apk --no-cache, --virtual for build deps), so fixing all misuses requires touching multiple RUN commands across Dockerfiles — slightly above e1 but contained within one component.
Closest to 'localised tax' (b3). The applies_to context is cli/Docker, meaning the burden is scoped to Dockerfile authoring. It doesn't permeate application code or architecture broadly, but every Dockerfile in a project must follow the correct patterns, creating a persistent but bounded maintenance tax on the team.
Closest to 'notable trap' (t5). The misconception field explicitly states that apt and apt-get are considered interchangeable by many developers, when they are not equivalent in scripting contexts. Additionally, common_mistakes show that cache-cleaning patterns and the need to run apt-get update before install are non-obvious gotchas that most developers encounter and learn — documented gotchas rather than catastrophic or architecture-breaking traps.
Also Known As
TL;DR
Explanation
Package managers resolve dependencies, verify signatures, and maintain package state. apt (Advanced Package Tool): apt install/remove/update/upgrade/autoremove, apt-cache search/show. dnf (replacing yum): dnf install/remove/update, dnf search. apk (Alpine — used in Docker): apk add/del/update/upgrade. Key differences: Alpine's apk is designed for minimal containers (no pkg-cache by default), apt uses .deb packages, dnf/yum uses .rpm. For PHP: ubuntu/debian use apt for PHP packages (ondrej/php PPA for multiple versions), Alpine uses apk. Security: always verify package signatures, use apt-key or dnf GPG checks.
Common Misconception
Why It Matters
Common Mistakes
- Not running apt update before apt install — installs outdated packages with stale package lists.
- No apt-get clean in Dockerfiles — package cache adds 50-100MB to image layers.
- apk --no-cache not used in Dockerfile — Alpine caches packages by default, bloating the image.
- Installing build tools without --virtual in apk — leaves build deps in production image.
Code Examples
# Bloated Dockerfile — cache not cleaned:
FROM ubuntu:22.04
RUN apt-get install -y php8.3-fpm
# Layer includes full apt cache: +100MB
# Alpine without --no-cache:
FROM alpine:3.19
RUN apk add php83-fpm
# Package cache retained: +30MB
# Clean apt cache in same layer:
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y php8.3-fpm \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Alpine with --no-cache — no package cache:
FROM alpine:3.19
RUN apk add --no-cache php83-fpm
# Install + clean in one RUN to minimise layer size:
RUN apk add --no-cache --virtual .build-deps \
gcc musl-dev \
&& docker-php-ext-install pdo_mysql \
&& apk del .build-deps # Remove build tools from final image