title: Dockerfile not using cache in RUN composer install command
body: <p>I thought i understand Docker already, but today i found some problem about utilizing docker cache.</p>
  
  <p>Here is my dockerfile</p>
  
  <pre><code>FROM quay.io/my_company/phpjenkins
  
  WORKDIR /usr/src/my_project
  ADD composer.json composer.json
  ADD composer.lock composer.lock
  
  RUN composer install -o
  
  ADD . .
  
  RUN mkdir -p temp/unittest/cache log
  
  RUN cp app/config/config.unittest.template.neon app/config/config.unittest.neon
  
  CMD ["tail", "-f", "/dev/null"]
  </code></pre>
  
  <p>I expect docker to use the cache until <code>ADD . .</code></p>
  
  <p>However, every build, look like docker try to do <code>composer install</code> every time.</p>
  
  <p>Here is some output</p>
  
  <pre><code>+ docker-compose -f docker-compose.yml run app vendor/bin/phpunit -d memory_limit=2048M
  Creating network "xxx_default" with the default driver
  Creating xxx_rabbitmq_1
  Creating xxx_mysql_1
  Building app
  Step 1/9 : FROM quay.io/my_company/phpjenkins
   ---&gt; f10ea65fb7df
  Step 2/9 : WORKDIR /usr/src/my_project
   ---&gt; Using cache
   ---&gt; 07ad76770cd2
  Step 3/9 : ADD composer.json composer.json
   ---&gt; Using cache
   ---&gt; 0d22314b81af
  Step 4/9 : ADD composer.lock composer.lock
   ---&gt; Using cache
   ---&gt; 3d41825efcb3
  Step 5/9 : RUN composer install -o
   ---&gt; Running in 38de5f08eb46
  Warning: This development build of composer is over 60 days old. It is recommended to update it by running "/usr/local/bin/composer self-update" to get the latest version.
  Do not run Composer as root/super user! See https://getcomposer.org/root for details ....
  ...
   ---&gt; aa05dc9ddc5f
  Removing intermediate container 581aa7e4b00f
  Step 6/9 : ADD . .
   ---&gt; 8796a9235b9a
  Removing intermediate container b7354231fbd7
  </code></pre>
  
  <p>I run out of lead, what could be possible thing that dockerfile didn't use cache for <code>RUN composer install</code> command</p>
  
  <p>I'm using <code>Docker version 17.05.0-ce, build 89658be</code> on Debian, if this help for investigation.</p>
  
  <p>Please advise.</p>