2017-09-18 54 views
2

司機我試圖安裝mongocxx司機在碼頭工人的容器,和步數之一是使用軟件包管理器安裝蒙戈-C驅動程序。我的瘦身Dockerfile:安裝蒙戈C和C++在多克

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的步驟失敗,無法找到libbson包

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配置它幾乎就好像什麼也沒有INSTAL搜索的libmongoc-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實例中安裝的經驗?有什麼洞察到這裏出了什麼問題?

+0

你有沒有成功地構建了C驅動,然後mongocxx * *外泊塢窗容器?我首先驗證你的程序是否有效。 – acm

回答

0

在我寫了那條評論之後,我想我在你的程序中發現了錯誤。您正在安裝「運行時」程序包,而不是開發包。嘗試安裝libmongoc-dev和libbson-dev。這些應該提供所需的頭文件和SONAME符號鏈接,以便您可以構建C++驅動程序。下面

1

行之有效的建設我的搬運工圖像

FROM ubuntu:16.04 
RUN apt-get -y update \ 
    && apt-get -y upgrade 

RUN apt-get install -y \ 
    openssh-server \ 
    g++ \ 
    cmake \ 
    git 

#installing the mongoc dependencies and driver 
RUN apt-get install -y \ 
    pkg-config \ 
    libssl-dev \ 
    libsasl2-dev 

RUN cd ~ \ 
    && wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.2/mongo-c-driver-1.6.2.tar.gz \ 
    && tar xzf mongo-c-driver-1.6.2.tar.gz \ 
    && cd mongo-c-driver-1.6.2 \ 
    && ./configure --disable-automatic-init-and-cleanup \ 
    && make \ 
    && make install \ 
    && cd ~ \ 
    && rm mongo-c-driver-1.6.2.tar.gz \ 
    && rm -rf mongo-c-driver-1.6.2 

#installing mongocxx driver - connects c++ to mongo 
RUN cd ~ \ 
    && wget https://github.com/mongodb/mongo-cxx-driver/archive/r3.1.1.tar.gz \ 
    && tar -xzf r3.1.1.tar.gz \ 
    && cd mongo-cxx-driver-r3.1.1/build \ 
    && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \ 
    && make EP_mnmlstc_core \ 
    && make \ 
    && make install \ 
    && cd ~ \ 
    && rm r3.1.1.tar.gz \ 
    && rm -rf mongo-cxx-driver-r3.1.1