Docker没有正确caching我的RUN命令

我有以下的Dockerfile …

FROM python:2.7-onbuild MAINTAINER Ewan Valentine <ewan@theladbible.com> # Various Python and C/build deps RUN apt-get update && apt-get install -y \ wget \ build-essential \ cmake \ git \ pkg-config \ python-dev \ python-opencv \ libopencv-dev \ libav-tools \ libjpeg-dev \ libpng-dev \ libtiff-dev \ libjasper-dev \ libgtk2.0-dev \ python-numpy \ python-pycurl \ libatlas-base-dev \ gfortran \ webp \ python-opencv # Install Open CV - Warning, this takes absolutely forever RUN cd ~ && git clone https://github.com/Itseez/opencv.git && \ cd opencv && \ git checkout 3.0.0 && \ cd ~ && git clone https://github.com/Itseez/opencv_contrib.git && \ cd opencv_contrib && \ git checkout 3.0.0 && \ cd ~/opencv && mkdir -p build && cd build && \ 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=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=OFF .. && \ make -j4 && \ make install && \ ldconfig 

但是,每次重新构build容器时,都会重新运行这两个RUN命令。 而通常情况下,我希望如果没有对它们进行更改,那么将跳过这些内容。