title: speeding up 'apt-get update' to speed up Docker image builds
body: <p>I want to add <code>curl</code> to a Docker image, and I'm using the following commands to in a Dockerfile to do so:</p>
  
  <pre><code>RUN apt-get update
  RUN apt-get install curl ca-certificates -y
  </code></pre>
  
  <p>My issue is that the initial update takes a pretty long time to run (2 min), so while I'm debugging my Dockerfile, iteration is slow. In particular when I make changes before the <code>RUN apt-get update</code>, which invalidate Docker's image cache.</p>
  
  <p>Is there any way to be more selective with <code>apt-get update</code>, so it only updates enough to index where to download <code>curl</code>? Or some other technique I can use to speed up my Docker builds?</p>
  
  <p>Here is the whole Dockerfile,</p>
  
  <pre><code>FROM postgres:9.6.10
  ADD data/tsvs.tar.gz /standard_data
  COPY postgres/*.sql /docker-entrypoint-initdb.d/
  
  RUN apt-get update
  RUN apt-get install curl ca-certificates -y
  RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
  RUN apt-get install postgis postgresql-9.6-postgis-scripts -y
  </code></pre>
  
  <p>I'm currently making changes to the SQL files in postgres/*.sql, hence the cache invalidation.</p>