Actuality I managed to solve it.
The issue was in the libressl that my docker build was using, I replaced it with the openSSL and all of the sudden it started working like a charm. I guess mongo driver for php had some issues with compiling ssl layer or something related libressl.
Thank you for your help.