Caching Docker Base Image in CircleCI

I currently have a base image (ubuntu + node + some core dependencies) that is 4GB large and takes about 3.5min~ to pull from dockerhub. I’m trying to speed this up because that’s an incredible amount of resources and time needed in order to run simple unit tests against my application.

Is there any way circle can cache the base image so the image doesn’t have to be downloaded on every build?

Another alternative is to use docker layer caching inside circleci, but it seems a bit backwards. Basically what i’d do in circleci is:

  • run a base ubuntu machine
  • checkout code
  • run dockerfile and build image (this caches the image layers for future builds on the same branch)
  • take latest image and run it in a container
  • inside the container(which has all my dependencies), checkout code and run tests

I would prefer not to do this alternative. Please advise!

We are in the same boat; speeding up builds by caching the env is a tradeoff with larger image sizes.

Status: Downloaded newer image ...
  pull stats: download 2.226GiB in 26.833s (84.94MiB/s), extract 2.225GiB in 2m46.246s (13.71MiB/s)
  time to create container: 510ms
...

Perhaps the upcoming pull rate limits in Docker Hub will encourage CI services to cache image layers.

You’d think local caching would be cheaper than CPU time + inbound bandwidth, saving us :timer_clock: & :moneybag:.