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.
Disclaimer
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!
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 quay.io for example)?
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:
dependencies:
cache_directories:
- "~/docker"
override:
- >-
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
else
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
fi