Let’s suppose you wanted to install the PDO extension. Here’s how.
Create your custom Dockerfile:
FROM php:8.2-fpm RUN docker-php-ext-install pdo_mysql
The docker-php-ext-install command is provided by the official
docker build php-with-pdo .
Test that extension was installed
docker run -it --rm my-php-image php -m | grep pdo_mysql
You should see
pdo_mysql printed out in the console.