title: Circle CI Docker service does not cache COPY
body: <p>I'm running docker on <a href="https://circleci.com">CircleCI</a> and I'm having trouble caching COPY commands.</p>
  
  <p>The Circle CI docs mention <a href="https://circleci.com/docs/docker#some-known-caching-issues">known caching issues</a> and recommend using <a href="https://git.wiki.kernel.org/index.php/ExampleScripts#Setting_the_timestamps_of_the_files_to_the_commit_timestamp_of_the_commit_which_last_touched_them">this perl script</a> to set the timestamps on the file copied over to preserve cache. </p>
  
  <p>The <a href="https://docs.docker.com/articles/dockerfile_best-practices/">Docker best practice docs</a> state: </p>
  
  <blockquote>
    <p>In the case of the ADD and COPY instructions, the contents of the
    file(s) being put into the image are examined. Specifically, a
    checksum is done of the file(s) and then that checksum is used during
    the cache lookup.</p>
  </blockquote>
  
  <p>As per the CircleCi recommendations, I am saving the cache to disk then loading it again on the next test run. This seems to be working as commands prior to COPY cache correctly.</p>
  
  <p>To debug, I'm outputting the md5 checksum of the file I am trying to copy locally, then from the docker container and it matches correctly. So, in theory the cache should load. I am not sure Docker uses md5 as a checksum.</p>
  
  <p>This is my current circle.yml:</p>
  
  <p>machine:
    services:
      - docker</p>
  
  <pre><code>dependencies:
    cache_directories:
      - "~/docker"
    pre:
      - mkdir -p ~/docker
    override:
      - docker info
      - if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
      - docker images
      - docker build -t circles .
  
  checkout:
    post:
      - ls -l
      - ./timestamp-set-to-git.pl
      - ls -l
  
  test:
    override:
      - md5sum .bowerrc
      - docker run circles md5sum .bowerrc
      - docker save circles &gt; ~/docker/image.tar
  </code></pre>
  
  <p>This is what the build outputs for the checksum steps:</p>
  
  <pre><code>$md5sum .bowerrc
  8d1a712721d735bd41bf738cae3226a2 .bowerrc
  
  $docker run circles md5sum .bowerrc
  8d1a712721d735bd41bf738cae3226a2 .bowerrc
  </code></pre>
  
  <p>But the <code>docker build</code> reports this:</p>
  
  <pre><code>Step 6 : RUN sudo npm install -g phantomjs gulp
   ---&gt; Using cache
   ---&gt; a7bbf2b17977
  Step 7 : COPY .bowerrc /var/work/.bowerrc
   ---&gt; 7ad82336de64
  </code></pre>
  
  <p>Does anyone know why COPY is not caching?</p>