我不确切知道Docker中的缓存是如何工作的,所以如何在Docker文件中修改此部分,以便Docker每次都不重建它?
# INSTALL OPENCV 3.1
WORKDIR /root
RUN wget https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip -O opencv_contrib-3.1.0.zip -nv && \
unzip opencv_contrib-3.1.0.zip && \
rm -f /root/opencv_contrib-3.1.0.zip && \
wget https://github.com/Itseez/opencv/archive/3.1.0.zip -O opencv-3.1.0.zip -nv && \
unzip opencv-3.1.0.zip && \
rm -f /root/opencv-3.1.0.zip
RUN export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:/usr/local/cuda-7.0/lib:$LD_LIBRARY_PATH
WORKDIR /root/opencv-3.1.0
RUN mkdir build && cd build && \
cmake -D CUDA_ARCH_BIN=3.2 \
-D CUDA_ARCH_PTX=3.2 \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_V4L=ON \
-D BUILD_TIFF=ON \
-D WITH_QT=ON \
# -D USE_GStreamer=ON \
-D WITH_OPENGL=ON \
-D WITH_IPP=ON \
-D OPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib-3.1.0/modules \
-D BUILD_opencv_legacy=OFF .. && \
make -j8 && \
make install && \
echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf.d/opencv.conf && \
ldconfig && \
cp /root/opencv-3.1.0/build/lib/cv2.so /usr/lib/python2.7/dist-packages/cv2.so
RUN rm -rf /root/opencv-3.1.0 /root/opencv_contrib-3.1.0 # cleanup
答案 0 :(得分:0)
我认为问题在于你依赖于$ LD_LIBRARY_PATH,这是一个非确定性的构建时变量。尝试转义美元符号:\ $ LD_LIBRARY_PATH