cross platform alpine-based php 7.1 - 8.4 images
100K+
This repository builds and publishes PHP images optimized for both CLI and FPM use cases, tailored for various PHP versions and their minor releases. Our images are compatible with both ARM64 and x86_64 host architectures and integrate seamlessly with Laravel and other PHP frameworks.
To get a specific version of our PHP image, use:
docker pull mxmd/php:<VERSION>-<TYPE>
Where:
<VERSION> is the desired PHP major version with the latest minor release (e.g., 7.4), or you can specify a minor version (e.g., 7.1.33, 8.0.30).<TYPE> is either cli or fpm.For example, to pull the PHP 7.4.33 FPM image:
docker pull mxmd/php:7.4.33-fpm
Available versions of our images along with their Docker Hub links:
You can integrate our PHP images into your Docker Compose workflows:
services:
php74-fpm:
platform: linux/arm64/v8
image: mxmd/php:7.4.33-fpm
ports:
- "9000:9000"
volumes:
# real time sync for app php files
- .:/app
# cache laravel libraries dir
- ./vendor:/app/vendor:cached
# logs and sessions should be authorative inside docker
- ./storage:/app/storage:delegated
# cache static assets bc fpm doesn't need to update css or js
- ./public:/app/public:cached
# additional php config
- ./docker-conf/php-ini:/usr/local/etc/php/custom.d
env_file:
- .env
environment:
# tell PHP to scan for our mounted custom ini files - preferabbly mount with zz-custom.ini
- PHP_INI_SCAN_DIR=/usr/local/etc/php/conf.d/:/usr/local/etc/php/custom.d
# composer
- COMPOSER_AUTH=${COMPOSER_AUTH}
# these are CRITICAL for linux hosts - our entrypoint will skip these for macOS if they conflict with GID:20 on the container
- HOST_USER_UID=${HOST_USER_UID:-1000}
- HOST_USER_GID=${HOST_USER_GID:-1000}
# production flag will enable opcache and production php.ini settings
- HOST_ENV=${HOST_ENV:-production}
# our entrypoint uses the www-data user for cmd entry that's not php-fpm - swap to EXEC_AS_ROOT=1 if you wanna exec as the root user
- EXEC_AS_ROOT=0
...
php74-cli:
image: mxmd/php:7.4.33-cli
...
Note: Adjust volume paths or environment variables as per your project's requirements.
Ensure these environment variables exist on your host machine:
HOST_USER_GID
HOST_USER_UID
On macOS, you can set them in ~/.extra or ~/.bash_profile.
To get HOST_USER_UID:
id -u
To get HOST_USER_GID:
id -g
To set these on your host machine:
echo "export HOST_USER_GID=$(id -g)" >> ~/.bash_profile && echo "export HOST_USER_UID=$(id -u)" >> ~/.bash_profile && echo "export DOCKER_USER=$(id -u):$(id -g)" >> ~/.bash_profile
Enabling the following environment variable activates the opcache and uses php.ini production settings:
HOST_ENV=production
Content type
Image
Digest
sha256:88e1d7eb4…
Size
59 MB
Last updated
4 days ago
docker pull mxmd/php:8.0-fpm-202609121529