PHP Docker Image
A small Alpine-based PHP 8.4 image with Composer, FPM and cron built in.
Overview
A minimal, production-ready PHP runtime built on the official php:*-alpine images. It ships the extensions most
PHP applications need, Composer 2, and runs as a non-root app user, so the same image can run a script on your
laptop, Composer in a CI job and PHP-FPM behind a web server without anyone setting up PHP by hand.
What’s inside
- Extensions: bcmath, bz2, calendar, exif, ftp, gd, gettext, gmp, intl, mysqli, opcache, pdo_mysql, pcntl, redis, shmop, soap, sockets, sodium, sysvmsg, sysvsem, sysvshm, tidy, xsl and zip.
- Debugging on demand: xdebug and pcov are installed but off; start the container with
DEBUG_ENABLED=1to turn them on. - Composer 2 with a cache you can mount at
/.composer. - Entrypoints:
run-fpmstarts PHP-FPM,run-cronstarts the cron daemon and installs/app/crontabif present (CRONTAB_FILEoverrides the path). - Non-root: processes run as the
appuser (UID 1000).
Usage
Run a PHP command without installing PHP locally:
docker run -it --rm ghcr.io/awesoft/php:8.4 php -v
Mount the current directory at /app and work inside the container:
docker run -it --rm -v $(pwd):/app ghcr.io/awesoft/php:8.4
Serve an application with PHP-FPM and run scheduled jobs from the same image:
docker run -d -v $(pwd):/app ghcr.io/awesoft/php:8.4 run-fpm
docker run -d -v $(pwd):/app ghcr.io/awesoft/php:8.4 run-cron