Docker machine executor cache workaround



As it looks like it may be a while until Circle has docker image caching working on 2.0 I thought I’d share our current workaround for enabling caching on the machine executor.

This is in response to the following topics:

The issue with rebuilding comes from a security patch (in 1.10.1 I believe) which prevents the current system from using the buildcache from a pulled or loaded image. The additional functionality to re-enable this process landed in docker API 1.25 so we need to upgrade the version of docker running on the VM (there is a feature request for this already). The following build step upgrades to the latest version of docker community edition (API 1.26 as of the posting date) and takes about 30 seconds to run, this has not caused any adverse affect for us on Circle but YMMV.

      - type: shell
        name: Update docker
        command: |
          # Remove docker engine
          sudo apt-get remove docker-engine
          # Install docker
          curl -fsSL | sudo apt-key add -
          sudo chmod 777 /etc/apt/sources.list.d/docker.list
          sudo echo "deb [arch=amd64] trusty stable" > /etc/apt/sources.list.d/docker.list
          sudo apt-get update -o Dir::Etc::sourcelist="sources.list"
          sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/docker.list"
          sudo apt-get install --yes docker-ce

Now to instruct docker to use a pulled or loaded image as a build cache you need to pass --cache-from to the docker cli ( or cachefrom parameter to the docker API (

Caching should now work when pulling images from the registry or when following this process as we do:

  • Docker save image to tar
  • Cache tar file using cache step in circleci
  • Restore cache on next build
  • Docker load tar file
  • Pass cachefrom to docker build


We natively support layer caching on the machine at this time:


Can you tell us what the additional fee is for the native solution?