Lets consider these commands:
We starting docker image with php 7.2 based on alpine.
docker run -it php:7.2-fpm-alpine3.7 sh
We trying to install php-mongodb as any other extension
docker-php-ext-install mongodb
But we obtaining error:
error: /usr/src/php/ext/mongodb does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name
...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see docker-php-ext-configure
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
I found some images of php with installed mongodb drivers:
https://github.com/Vinelab/docker-php-mongo
All with the same command:
pecl install mongodb
Have docker-php-ext-install
any advantages over pecl
? I saw that most extensions is installed by docker-php-ext-install
. I found this question without answer in issue:
If pecl contains all extensions, but docker-php-ext-install
allow to install constrained list, why it was created?
The answer may become irrelevant to the question. Still, I am adding the following snippet in case someone comes here as I did and can install mongodb extension for php in a docker container. I am using php7.3-fpm. https://www.php.net/manual/en/mongodb.installation.pecl.php
RUN pecl install mongodb \
&& echo "extension=mongodb.so" > $PHP_INI_DIR/conf.d/mongo.ini
My docker kept complaining that it could not find the mongo.so extension. Finally i figured it out to run the following
RUN apt-get install -y openssl libssl-dev libcurl4-openssl-dev
RUN pecl install mongodb-1.6.0
RUN docker-php-ext-enable /usr/local/lib/php/extensions/no-debug-non-zts-20180731/mongodb.so
It seems like docker wants that you enable a php extension via docker-php-ext-enable
您可以在官方php
图像存储库中的docker-php-ext-install vs pecl 问题中找到解释
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.