acc-docker-base-images-knowledge
1
总安装量
1
周安装量
#46677
全站排名
安装命令
npx skills add https://github.com/dykyi-roman/awesome-claude-code --skill acc-docker-base-images-knowledge
Agent 安装分布
opencode
1
claude-code
1
Skill 文档
Docker Base Images Knowledge Base for PHP
Guidelines for selecting and managing PHP Docker base images.
PHP Official Images Overview
| Image Tag Pattern | Base OS | Size | Use Case |
|---|---|---|---|
php:8.4-fpm |
Debian Bookworm | ~480MB | Production FPM (full compatibility) |
php:8.4-fpm-alpine |
Alpine 3.20 | ~80MB | Production FPM (minimal size) |
php:8.4-cli |
Debian Bookworm | ~450MB | CLI scripts, cron jobs, workers |
php:8.4-cli-alpine |
Alpine 3.20 | ~50MB | Lightweight CLI tasks |
php:8.4-apache |
Debian Bookworm | ~500MB | All-in-one Apache+PHP |
php:8.4-zts |
Debian Bookworm | ~460MB | Thread-safe (parallel ext) |
php:8.4-zts-alpine |
Alpine 3.20 | ~85MB | Thread-safe minimal |
Alpine vs Debian Comparison
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â ALPINE vs DEBIAN FOR PHP CONTAINERS â
ââââââââââââââââââââââ¬âââââââââââââââââââââââââ¬ââââââââââââââââââââââââââââââââ¤
â Criterion â Alpine (musl) â Debian (glibc) â
ââââââââââââââââââââââ¼âââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââ¤
â Image Size â ~80MB (FPM) â ~480MB (FPM) â
â C Library â musl libc â glibc â
â Package Manager â apk â apt â
â Security Updates â Fast, frequent â Regular, well-tested â
â DNS Resolver â musl (simpler) â glibc (full-featured) â
â Locale Support â Limited â Full â
â iconv â GNU libiconv needed â Works out of the box â
â Compatibility â Most PHP apps OK â All PHP apps â
â Build Speed â Faster (smaller dl) â Slower (larger packages) â
â Debug Tools â Limited â Comprehensive â
â gRPC / Protobuf â May need workarounds â Works natively â
â Image Scanning â Fewer CVEs reported â More CVEs (more packages) â
ââââââââââââââââââââââ´âââââââââââââââââââââââââ´ââââââââââââââââââââââââââââââââ
Image Selection Decision Tree
Start
â
âââ Need Apache built-in?
â âââ YES âââ¶ php:8.4-apache
â
âââ Need PHP-FPM (web)?
â âââ Need full glibc compatibility?
â â âââ YES âââ¶ php:8.4-fpm (Debian)
â â âââ NO âââ¶ php:8.4-fpm-alpine
â â
â âââ Using gRPC/protobuf?
â â âââ YES âââ¶ php:8.4-fpm (Debian)
â â
â âââ Need locale/intl precision?
â â âââ YES âââ¶ php:8.4-fpm (Debian)
â â
â âââ Default âââ¶ php:8.4-fpm-alpine
â
âââ CLI workers / cron / queue consumers?
â âââ php:8.4-cli-alpine (or cli for glibc)
â
âââ Need parallel extension (ZTS)?
âââ php:8.4-zts-alpine (or zts for glibc)
Version Pinning Strategies
| Strategy | Example | Stability | Updates |
|---|---|---|---|
| Full pin | php:8.4.2-fpm-alpine3.20 |
Highest | Manual only |
| Minor pin | php:8.4-fpm-alpine |
High | Patch auto |
| Major pin | php:8-fpm-alpine |
Medium | Minor auto |
| Latest | php:latest |
Lowest | All auto |
Recommended for production: Full pin or minor pin with CI rebuild schedule.
# Full pin (most reproducible)
FROM php:8.4.2-fpm-alpine3.20
# Minor pin (recommended balance)
FROM php:8.4-fpm-alpine
# AVOID in production
FROM php:latest
FROM php:fpm
Common Alpine Issues and Solutions
DNS Resolution
musl DNS resolver behaves differently from glibc. May cause issues with service discovery.
# Fix: Add DNS options
RUN echo "options ndots:0" >> /etc/resolv.conf
iconv Issues
Alpine uses musl iconv which has limited charset support.
# Fix: Install GNU libiconv
RUN apk add --no-cache gnu-libiconv
ENV LD_PRELOAD=/usr/lib/preloadable_libiconv.so
Locale Support
Alpine has minimal locale support by default.
# Fix: Install locale data for intl
RUN apk add --no-cache icu-data-full
Missing Shared Libraries
Some PECL extensions expect glibc-specific libraries.
# Fix: Install compatibility layer (use sparingly)
RUN apk add --no-cache gcompat
Image Lifecycle Best Practices
| Practice | Description |
|---|---|
| Pin digest in CI | Use php:8.4-fpm-alpine@sha256:abc... for fully reproducible builds |
| Rebuild weekly | Scheduled CI rebuild picks up security patches |
| Scan images | Use trivy image app:latest or docker scout |
| Track upstream | Monitor docker-library/php for breaking changes |
| Test Alpine compat | Run full test suite against Alpine image before adopting |
References
For detailed image variant comparison, see references/image-comparison.md.
For extension installation on different bases, see acc-docker-php-extensions-knowledge.