Php: How to disable unused php base extensions

Created on 10 Apr 2020  路  4Comments  路  Source: docker-library/php

php:fpm-alpine adds bunch of extensions.
How can I remove or at least disable extension that I don't want to use: ftp, sqlite3, pdo_sqlite and more?

After all extensions disabled in php.ini, here is the list what php modules still are running:

# php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

I have noticed that also proposed https://github.com/docker-library/php/issues/220 has been rejected.

Know when installed php with apk add php it will result not so long list of php modules:

# php -m
[PHP Modules]
Core
date
filter
hash
libxml
pcre
readline
Reflection
SPL
standard
zlib

[Zend Modules]
Request question

Most helpful comment

@phy25 I think clean build shouldn't add any extensions that php couldn't run without, especially not in a way without ability yo remove or disable it. I consider it as docker php package bug.

There are other docker images offering to define list of wished php extensions in docker-compose.yml arguments that would auto install it without breaking on dependencies like this php image, that tries to workaround falling into this issue or in errors by missing dependent packages. Hope we can make things better.

All 4 comments

These are likely not compiled as separate extensions; see the flags to configure for why each is included:

https://github.com/docker-library/php/blob/d8bb468ec3a1e3ff5ad910ee8db02d9a6615d6de/Dockerfile-alpine.template#L116-L154

But why you want to do this?

Have you read the template comments to see why those are included?

@phy25 I think clean build shouldn't add any extensions that php couldn't run without, especially not in a way without ability yo remove or disable it. I consider it as docker php package bug.

There are other docker images offering to define list of wished php extensions in docker-compose.yml arguments that would auto install it without breaking on dependencies like this php image, that tries to workaround falling into this issue or in errors by missing dependent packages. Hope we can make things better.

Was this page helpful?
0 / 5 - 0 ratings