I am currently building a base image for my project. The project is using mongodb. I’ve successfully created the image but an error shows up when I try to call the endpoint which is related with SSL on libmongoc:
The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL
Below are the some notable stuffs about my docker image:
- alpine 3.8
- php 7.2
- nginx
- lumen-framework 5.6.*
Below are the current implementation which has the problem, your suggestions are appreciated:
FROM alpine:3.8
RUN apk update && apk upgrade
RUN apk --no-cache add composer curl gcc git make musl-dev nginx
openssl openssl-dev php7 php7-ctype php7-curl php7-dev
php7-dom php7-fileinfo php7-fpm php7-gd php7-iconv
php7-imagick php7-intl php7-json php7-mbstring php7-mysqli
php7-opcache php7-openssl php7-pdo php7-pdo_mysql php7-pear
php7-redis php7-simplexml php7-tokenizer php7-xdebug
php7-xmlreader php7-xmlwriter php7-zip php7-zlib supervisor tzdata
RUN pecl install mongodb
&& pecl config-set php_ini /etc/php7/php.ini
&& echo "extension=mongodb.so" > /etc/php7/conf.d/20_mongodb.ini
Aside from above Dockerfile, I also tried to manually build the mongo-php-driver based on this article , but it doesn’t help. Both options still show me that SSL is disabled when I check with php -i | grep mongo
. Do tell me if I need to include another information.
2
Answers
The original post was over a year ago. But I also was trumped by this error:
The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL
.The solutions below assume that you have a docker-compose configuration for mongodb.
My solution was to first stop and remove the container that is implementing mongoDB … call that container
workspace
:Stack:
Dockerfile work for creation of mongodb extension
Build the container
Bashing into the container:
docker-compose exec workspace bash
Verify SSL Enabled on libmongoc
Response is:
Run the commands in the following order-
Then make sure all the downloaded modules were placed in the extension directory which is detailed in the php.ini’s
phpinfo()
Then add
extension=“libmongoc.so”
and#extension=“mongodb.so”
to php.ini.Then finally remember to restart the machine or docker container in your instance.