Docker – Adams Bros Blog http://blog.adamsbros.org Mon, 26 Jun 2017 04:30:39 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.2 Docker Building – Caching http://blog.adamsbros.org/2017/06/25/docker-building-caching/ http://blog.adamsbros.org/2017/06/25/docker-building-caching/#respond Mon, 26 Jun 2017 04:20:12 +0000 http://blog.adamsbros.org/?p=644 So you’re interested in creating your own docker image?  You keep finding it takes several minutes per run, which is a real pain.  No problem, cache everything!

  1. Wander over to Docker Squid and start using their squid in a docker image.
  2. Once the docker container is up and running, modify their /etc/squid3/squid.conf to change the cache_dir to allow 10G of storage and cache large objects such as 200M (default is only 512kb).  There is an existing line, so search with a regex for “^cache_dir”.  Then change the entire line to something like “cache_dir ufs /var/spool/squid3 10000 16 256 max-size=200000000“, which results in 10G of cache and 200M objects being cachable.
  3. Change your Dockerfile to use a RUN line with exports for http_proxy, https_proxy, and ftp_proxy, to point to your host’s IP and port 3128.  Don’t use ENV, as that will permanently set those for the container once it’s created and running. My line looks like “RUN export http_proxy=http://192.168.2.5:3128; export https_proxy=http://192.168.2.5:3128; export ftp_proxy=http://192.168.2.5:3128; \

Doing this took my docker builds from 6-7 minutes down to about 1.5 minutes.

]]>
http://blog.adamsbros.org/2017/06/25/docker-building-caching/feed/ 0