Sign inSign up

gerald77/php8-docker

By gerald77

•Updated 6 days ago

Docker PHP8 + php extensions for piwigo (alpine)

Image
0

749

gerald77/php8-docker repository overview

⁠php8-docker

PHP 8 FPM on Alpine Linux with the PHP extensions needed by web applications such as Piwigo⁠: MySQL support, EXIF and GD with JPEG and FreeType.

Based on the official php:8-fpm-alpine⁠ image and rebuilt regularly with current security patches.

⁠Included PHP extensions

ExtensionPurpose
mysqli, pdo, pdo_mysqlMySQL / MariaDB access
exifRead photo metadata
gd (with JPEG and FreeType)Image processing, thumbnails, text rendering

All other extensions are those of the official PHP image, unchanged. ImageMagick (imagick) is not included. If you need more extensions, build your own image with FROM gerald77/php8-docker.

⁠Quick start

PHP-FPM speaks FastCGI, so you need a web server such as Nginx in front of it.

docker network create web

docker run -d --name php --network web \
    -v /path/to/your/site:/var/www/html \
    gerald77/php8-docker:latest

⁠Docker Compose with Nginx

services:
  php:
    image: gerald77/php8-docker:latest
    container_name: php8-docker
    restart: unless-stopped
    environment:
      - TZ=Europe/Vienna
    volumes:
      - ./site:/var/www/html

  nginx:
    image: nginx:stable-alpine
    container_name: nginx
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./site:/var/www/html:ro
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - php

Minimal nginx.conf:

server {
    listen 80;
    root /var/www/html;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass php:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

The web root must be mounted at the same path in both containers so that SCRIPT_FILENAME resolves correctly.

⁠Configuration

Use the standard mechanisms of the official PHP image: mount a .ini file to /usr/local/etc/php/conf.d/ (e.g. upload_max_filesize, memory_limit) or a pool file to /usr/local/etc/php-fpm.d/.

    volumes:
      - ./custom.ini:/usr/local/etc/php/conf.d/custom.ini:ro

⁠Notes

  • Do not publish port 9000 to the internet; PHP-FPM has no authentication. Keep it on an internal Docker network.
  • The image is rebuilt automatically on every push to the source repository; pull regularly to get security updates.

⁠License

The Dockerfile and related files of this project are licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE⁠ file in the source repository.

PHP is licensed under the PHP License⁠. Alpine Linux and other included software are under their respective licenses; see the files in /usr/share/licenses and /usr/share/doc inside the container.

⁠Disclaimer

THIS IMAGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR MAINTAINERS BE LIABLE FOR ANY CLAIM, DAMAGES, DATA LOSS OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE IMAGE OR ITS USE.

Use at your own risk. You are responsible for securing your deployment (network access, updates, application code) and for backing up your data.

Tag summary

Content type

Image

Digest

sha256:7f1b25ff9…

Size

38 MB

Last updated

6 days ago

docker pull gerald77/php8-docker