Dockerfile build RUN cmd fails but works from interactive
<p>I'm running into an issue where building a Dockerfile fails at a 'make' command but if I run -it the container and make again it succeeds. Specifically the make command seems to be not seeing a file:</p>

<pre><code>make[2]: *** No rule to make target /usr/local/nvidia/lib64/libcuda.so, needed by bin/gpu-example-alpha_comp. Stop.
</code></pre>

<p>But this is based on nvidia/cuda:8.0-cudnn5-devel and libcuda.so is there, i.e. if I run -it the container:</p>

<pre><code>root@cf5637b85467:/opt/opencv/opencv/build# ll /usr/local/nvidia/lib64/libcuda*.*
lrwxrwxrwx 1 999 999 17 Nov 21 20:42 /usr/local/nvidia/lib64/libcuda.so -&gt; libcuda.so.370.28
lrwxrwxrwx 1 999 999 17 Nov 21 20:42 /usr/local/nvidia/lib64/libcuda.so.1 -&gt; libcuda.so.370.28
-rw-r--r-- 2 root root 8219624 Sep 2 02:25 /usr/local/nvidia/lib64/libcuda.so.370.28
</code></pre>

<p>and make completes without issue if I manually run it (I tried running from both /bin/bash and /bin/sh).</p>

<p>The only thing I can see is the user &amp; group 999 of the .so link, but I don't know if that's relevant. In the worst case I could commit after building, but this seems a bad approach going forward. Any suggestions? Full Dockerfile below:</p>

<pre><code>FROM nvidia/cuda:8.0-cudnn5-devel

RUN apt-get update &amp;&amp;\
    apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    curl \ 
    gfortran \
    git \
    libatlas-base-dev \
    libavcodec-dev \
    libavformat-dev \
    libfreetype6-dev \
    libgtk2.0-dev \
    libjasper-dev \
    libjpeg8-dev \
    libpng12-dev \
    libswscale-dev \
    libtiff4-dev \
    libv4l-dev \
    pkg-config \
    python2.7-dev \
    &amp;&amp; \
    apt-get clean &amp;&amp; \
    apt-get autoremove &amp;&amp; \
    rm -rf /var/lib/apt/lists/*

# Get pip and pip installs
RUN curl -O https://bootstrap.pypa.io/get-pip.py &amp;&amp; \
    python get-pip.py &amp;&amp; \
    rm get-pip.py

RUN pip --no-cache-dir --timeout=60 install \
    numpy

# Install opencv and opencv_contrib
WORKDIR /opt/opencv
RUN git clone --depth 1 https://github.com/opencv/opencv.git &amp;&amp; \
    git clone --depth 1 https://github.com/opencv/opencv_contrib.git

WORKDIR /opt/opencv/opencv/build
RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
            -D CMAKE_INSTALL_PREFIX=/usr/local \
            -D INSTALL_C_EXAMPLES=ON \
            -D INSTALL_PYTHON_EXAMPLES=ON \
            -D OPENCV_EXTRA_MODULES_PATH=/opt/opencv/opencv_contrib/modules \
            -D CUDA_CUDA_LIBRARY=/usr/local/nvidia/lib64/libcuda.so \
            -D BUILD_EXAMPLES=ON ..
RUN make -j8 
RUN make install 
</code></pre>