Example PHP-FPM 8.3+ & Nginx 1.26+ container image for Docker, built on Alpine Linux.
- Built on the lightweight and secure Alpine Linux distribution
- Multi-platform, supporting AMD4, ARMv6, ARMv7, ARM64
- Small Docker image size (+/-115MB) with composer and Common php extensions.
- Support PHP 8.2 ~ 8.4, low CPU usage & memory footprint
- Optimized for 100 concurrent users
- Optimized to only use resources when there's traffic (by using PHP-FPM's
on-demandprocess manager) - The services Nginx, PHP-FPM and supervisord run under a non-privileged user (nobody) to make it more secure
- The logs of all the services are redirected to the output of the Docker container (visible
with
docker logs -f <container name>) - Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs
The goal of this container image is to provide a base image for running Nginx and PHP-FPM in a container which follows the best practices and is easy to understand and modify to your needs.
docker build -t alpine-php:latest --rm .Or build your own customized image with args(environment, php version, timezone):
docker build --build-arg ENV=dev -t alpine-dev:latest --rm .docker run -itd -p 80:8080 --name alpine-php alpine-php:latestOr mount your own code to be served by PHP-FPM & Nginx
docker run -itd -p 80:8080 --name alpine-php -v ~/my-codebase:/var/www/project alpine-php:latestWill See the PHP info on http://localhost if success. Please replace localhost by your own IP or domain.
docker exec -it alpine-php shdocker logs -f alpine-phpdocker exec -it alpine-test4 composer installIn config/ you'll find the default configuration files for Nginx, PHP and PHP-FPM. If you want to extend or customize that you can just modify and change it.
To modify Dockerfile to your specific needs, please see the following examples:
This project is built upon TrafeX/docker-php-nginx and customized to better suit my requirements.