在Docker中安装Mongo C和C ++驱动程序

我正在尝试在Docker容器中安装mongocxx驱动程序,第一步是使用软件包pipe理器安装mongo-c驱动程序。 我瘦了Dockerfile:

FROM phusion/baseimage:latest RUN apt-get install -y libmongoc-1.0-0 

完成这一步后,我应该准备好按照以下说明安装cxx驱动程序: https : //mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/

 RUN git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 WORKDIR /mongo-cxx-driver/build RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. RUN make EP_mnmlstc_core RUN make && make install 

这一直进行到cmake步骤失败,无法findlibbson包

 Step 17/25 : RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. ---> Running in ba6033b680bb -- The CXX compiler identification is GNU 5.4.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- The C compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Checking for module 'libbson-1.0>=1.5.0' -- CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:367 (message): A required package was not found 

如果我尝试使用pkg-configsearchlibmongoc-1.0和libbson-1.0软件包,就好像没有从mongo-c驱动程序安装任何东西。

 Step 17/26 : RUN pkg-config --cflags --libs libmongoc-1.0 libbson-1.0 ---> Running in 343f3b4feb3b Package libmongoc-1.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `libmongoc-1.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libmongoc-1.0' found Package libbson-1.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `libbson-1.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libbson-1.0' found 

有没有人有在Docker实例中安装的经验? 任何洞察到这里出了什么问题?

在我写这个评论之后,我想我在你的程序中发现了错误。 您正在安装“运行时”程序包,而不是开发包。 尝试安装libmongoc-dev和libbson-dev。 这些应该提供所需的头文件和SONAME符号链接,以便您可以构buildC ++驱动程序。