Since PHP seems to be configured to load any ini files in the conf.d directory, I’d suggest creating a new ini file for mongodb there. Consider this in your docker file:

RUN echo "extension=mongodb.so" >> /usr/local/etc/php/conf.d/mongodb.ini

Running php --ri mongodb in the container should then show that the extension was loaded correctly.

3 Likes