README
sidebar_key: docker-php tags: [docker, php]
PHP Docker Images ByJG
Overview
A complete, lightweight, and versatile PHP Docker image collection based on Alpine Linux. These images are designed to be small, efficient, and ready to use in various environments.
Key Features
- Lightweight: Based on Alpine Linux, with optimized image sizes (~135-154MB)
- Multi-architecture support: Runs on amd64 (x86_64) and arm64 (Raspberry PI, Graviton)
- Multiple PHP versions: From PHP 5.6 to the latest PHP 8.6
- Variety of configurations: Base, CLI, FPM, FPM-Nginx, and FPM-Apache variants
- Pre-installed extensions: 45+ PHP extensions included in all images
- Development tools: Composer, PHPUnit, PHP Code Sniffer, and more in CLI images
- Production-ready: Optimized for both development and production environments
- Security-hardened: Runs as non-root user (
app), includes SBOM & build provenance
Documentation Index
- Base Image - Minimal image with 45+ extensions
- CLI Image - Command-line tools for development
- FPM Images - PHP-FPM, Nginx, and Apache variants
- Security Features - SBOM, Provenance, and Alpine version strategy
- Environment Variables - Configuration options
- Building Custom Images - Create your own images
- IDE Integration - Using with your IDE
- Dockerfile Reference - Dockerfile details
- Tagging Convention - Understanding image tags
See full documentation at: https://opensource.byjg.com/docs/devops/docker-php
Quick Start
# Pull an image
docker pull byjg/php:8.3-cli
# Run PHP
docker run -it --rm byjg/php:8.3-cli php --version
# Use with your project
docker run -v $PWD:/workdir -w /workdir byjg/php:8.3-cli php script.php
Image Variants
Five different images for each PHP Version:
| Image Type | Description |
|---|---|
base | Minimal image with 45+ PHP extensions and Composer |
cli | Development tools (PHPUnit, PHP_CodeSniffer, PHPMD) |
fpm | PHP-FPM for custom web server configurations |
fpm-nginx | Complete LEMP stack (Nginx + PHP-FPM) |
fpm-apache | Complete LAMP stack (Apache + PHP-FPM) |
Supported PHP Versions
| Version | Latest Version | Monthly Builds | Alpine Version |
|---|---|---|---|
| 8.6 ⚠ | 8.6.0alpha3 | yes | edge/testing |
| 8.5 | 8.5.9 | yes | edge |
| 8.4 | 8.4.24 | yes | edge |
| 8.3 | 8.3.33 | yes | edge |
| 8.2 | 8.2.31 | - | 3.22 |
| 8.1 | 8.1.31 | - | 3.19 |
| 8.0 | 8.0.30 | - | 3.16 |
| 7.4 | 7.4.33 | - | 3.15 |
| 7.3 | 7.3.33 | - | 3.12 |
| 7.2 | 7.2.33 | - | 3.9 |
| 7.1 | 7.1.33 | - | 3.7 |
| 7.0 | 7.0.33 | - | 3.5 |
| 5.6 | 5.6.40 | - | 3.8 |
⚠ PHP 8.6 is a pre-release (alpha). The images are meant for early testing only and do not
ship the redis, memcached and yaml extensions yet, since Alpine has not published them for
PHP 8.6.
PHP versions with monthly builds receive regular updates. Legacy versions (without monthly builds) are no longer supported.
Why Alpine edge? PHP 8.2-8.6 use Alpine edge to avoid critical unpatched vulnerabilities in Alpine 3.22, including CVE-2023-27482 (supervisor) and other security issues. Monthly tagged releases (YYYY.MM) provide stability checkpoints. See Security Features for details.
For Production: Pin to specific monthly tags for guaranteed reproducibility:
docker pull byjg/php:8.4-base-2025.11
Use Cases
These images are ready to use in:
- Development Environment - Fast setup with all tools included
- Production Environment - Optimized, lightweight containers
- CI/CD Pipelines - Travis-CI, Circle-CI, Jenkins, Bitbucket Pipelines, GitHub Actions
- IDE Integration - Full PHP support without local installation (see IDE Integration)
Image Sizes
Uncompressed sizes for reference:
| Build Type | Uncompressed Size |
|---|---|
| base | ~135MB |
| cli | ~154MB |
| fpm | ~139MB |
| fpm-nginx | ~154MB |
| fpm-apache | ~154MB |