-1
日增长
4,994
stars
432
forks
45
watchers
916
prs
434
issues
482
releases
README
[!NOTE]
A new version of this project is being developed at mlocati/install-php-extensions.
It's a rewrite in PHP that also works outside of the official PHP Docker images (for example, with the PHP installed by APT or APK).
It's not ready for production yet, but feedback is very welcome!
Easy installation of PHP extensions in official PHP Docker images
This repository contains a script that can be used to easily install a PHP extension inside the official PHP Docker images.
The script will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed so that the image will be much smaller.
Supported docker images are:
- Debian-based docker images: since jessie (Debian 8) (minimum PHP version: 5.5)
- Alpine-based docker images: since Alpine 3.9 (minimum PHP version: 7.1)
See also the notes in the Special requirements section.
Usage
You have many ways to use this script within your Dockerfiles.
Here's a list of sample Dockerfiles that install the GD and xdebug PHP extensions:
Downloading the script on the fly with ADD
Dockerfile
FROM php:7.2-cli
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd xdebug
Downloading the script on the fly with curl
Dockerfile
FROM php:7.2-cli
RUN curl -sSLf \
-o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions gd xdebug
Direct execution with curl
Dockerfile
FROM php:8.2-cli
RUN ( curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - || echo 'return 1' ) | sh -s \
gd xdebug
Copying the script from a Docker image
- using GitHub Container Registry
Dockerfile
FROM php:8.4-cli
COPY --from=ghcr.io/mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd xdebug
- using Docker Hub
Dockerfile
FROM php:8.4-cli
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd xdebug
Warning: by using this method you may use an outdated version of the Docker image.
You may want to run docker pull ghcr.io/mlocati/php-extension-installer or docker pull mlocati/php-extension-installer in order to use an up-to-date version.
Using the script of a Docker image
- using GitHub Container Registry
Dockerfile
RUN --mount=type=bind,from=ghcr.io/mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \
install-php-extensions gd xdebug
- using Docker Hub
Dockerfile
RUN --mount=type=bind,from=mlocati/php-extension-installer:lTop issues
#1179saxonc alpine arm645 comments · 2025-10-28#1292Add IPE_VIPS_MINIMAL env var to skip magick/openexr/libraw loaders in libvips3 comments · 2026-05-26#1049Support php-xz3 comments · 2025-01-22#997Trying to install OCI8 with caret constraint, but latest stable version was not installed 3 comments · 2024-10-29#917Add sqlanywhere to connect to sqlanywhere instances1 comments · 2024-04-27#818add BitOne/php-meminfo1 comments · 2023-10-18#1399saxonc fails to install0 comments · 2026-11-10#1313Support new Valkey GLIDE PHP extension0 comments · 2026-07-17
Discussions
#1386PHP 8.6 support1 comments · 2026-10-22#1339Consider tagged or manual releases (release spam)1 comments · 2026-09-18#1309ERROR - install failed1 comments · 2026-06-26#1278Missing ability to install rrd4 comments · 2026-04-24#1242Compatibility issue debugging (8.5 + smbclient + oci8)3 comments · 2026-03-05#1225Certificate error on download.microsoft.com2 comments · 2026-01-21#1191PHP 8.5 does not have imagick?4 comments · 2025-11-23#1181Microsoft ODCB Driver2 comments · 2025-11-02
Latest release
v2.13.2 2.13.2 2026-11-02- ioncube_loader: stop with a clear error when there's no musl loader for the architecture (1380)