I am working on a PHP API and I would like to disable unused php Modules inside my PHP-FPM image, such as “sqlite3, pdo ..”.
I am a docker beginner and I would like to know if is there anything similar to docker-php-ext-enable
if not what is the best practice for disabling unused php modules.
Advertisement
Answer
Finally I found the key point.
Inside docker php container, all the registered modules holds by a configuration file under the below path.
/usr/local/etc/php/conf.d/*.ini
bash
into the container:
docker exec -it php_container_name bash
You can list all the enabled modules by php -m
:
And cd
into that folder, you can see the relating config files:
cd /usr/local/etc/php/conf.d/ ls # output docker-php-ext-mcrypt.ini docker-php-ext-mysqli.ini docker-php-ext-opcache.ini opcache-recommended.ini docker-php-ext-zip.ini
To disable some extension module, make a dir disabled
, and move that .ini
file inside it, for example:
mkdir disabled mv docker-php-ext-opcache.ini disabled mv opcache-recommended.ini
Finally, press Ctrl+D
to exit the container, and then restart the container to make changes work.
docker restart php_container_name
You can get into the container and run php -m
to see, the relating extension is gone.