Docker无法安装MongoDB扩展

时间:2019-05-22 16:27:17

标签: php mongodb docker dockerfile

我正在尝试在docker映像中安装mongodb php驱动程序。

缩短的Dockerfile:

FROM php:7.2-fpm


RUN pecl install mongodb
RUN echo "extension=mongo.so" > $PHP_INI_DIR/conf.d/mongo.ini

稍后在我的Dockerfile中,我尝试根据mongodb扩展名安装一个composer应用程序。出现此错误:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mongo.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/mongo.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/mongo.so: 
cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/mongo.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/mongo.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

1 个答案:

答案 0 :(得分:1)

您将扩展名命名错误。代替extension=mongo.so,它应该是extension=mongodb.so。因此,您的示例将变为:

FROM php:7.2-fpm


RUN pecl install mongodb
RUN echo "extension=mongodb.so" > $PHP_INI_DIR/conf.d/mongodb.ini

引用mongodb installation