Workaround Docker cache issue with docker-cache-shim



Currently, CircleCI doesn’t support Docker cache very well. There is some workaround but sometimes it’s hard to use correctly.

Slightly better and easier approach is pushing your image to Docker Hub and pull the image before running docker build. In this way, you are using Docker Hub as cache store for your image.

I made docker-cache-shim to make this workflow easier for me. You can see it in action

I work in CircleCI but I wrote this post and docker-cache-shim personally, so please make Github issues when you have questions/problems, but not in CircleCI support ticket. Thanks!

Docker Cache
Caching Docker image with Docker Hub
Cache on `executorType: machine`

Thanks for creating this. I haven’t looked too in depth at the code, but would it be straightforward and make sense to add support for other registries (AWS ECR or for example)?


You should be able to use other repositories for caching. You just need to change the image path to pull/push.

docker-cache-shim pull

docker-cache-shim push


Just to confirm, will this work for Docker 1.10 as well?


Unfortunately not :frowning: Both load/save and pulling cache workarounds are broken in Docker 1.10.


Do you know when does CircleCI’s caching docker image work 100% ?


Wanted to share what I’m doing to cache docker images. I noticed that when I implemented CircleCI’s docker caching suggestion, the build was still pulling from the docker hub when running docker pull, even after the image was loaded from docker load.

This works very well for loading docker images from cache:

    - "~/docker"
    - >-
      if [[ -e ~/docker/go.1.7.3.tar ]]; then
        echo "Loading golang docker image from cache"
        docker load -i ~/docker/go.1.7.3.tar
        echo "Pulling golang docker image from Docker Hub"
        docker pull golang:1.7.3
        mkdir -p ~/docker; docker save -o ~/docker/go.1.7.3.tar golang:1.7.3