FrankenPHP Docker images are based on official PHP images. Alpine Linux and Debian variants are provided for popular architectures. Variants for PHP 8.2 and PHP 8.3 are provided. Browse tags.
Create a Dockerfile
in your project:
FROM dunglas/frankenphp
COPY . /app/public
Then, run the commands to build and run the Docker image:
$ docker build -t my-php-app .
$ docker run -it --rm --name my-running-app my-php-app
The docker-php-extension-installer
script is provided in the base image.
Adding additional PHP extensions is straightforwardd:
FROM dunglas/frankenphp
# add additional extensions here:
RUN install-php-extensions \
pdo_mysql \
gd \
intl \
zip \
opcache
# ...
Set the FRANKENPHP_CONFIG
environment variable to start FrankenPHP with a worker script:
FROM dunglas/frankenphp
# ...
ENV FRANKENPHP_CONFIG="worker ./public/index.php"
To develop easily with FrankenPHP, mount the directory from your host containing the source code of the app as a volume in the Docker container:
docker run -v $PWD:/app/public -p 80:80 -p 443:443 my-php-app
With Docker Compose:
# compose.yml
version: '3.1'
services:
php:
image: dunglas/frankenphp
# uncomment the following line if you want to use a custom Dockerfile
#build: .
# uncomment the following line if you want to run this in a production environment
# restart: always
ports:
- 80:80
- 443:443
volumes:
- ./:/app/public