Docker Layer Caching by Branch


#1

Is it possible to cache layers but only for the branch you are building for?

Say i build “docker build -t myacc/myapp:$CIRCLE_BRANCH .”

Is it possible to only cache for the tagged build? If not does it just cache general layers and only rebuild on some edited account of the dockerfile?

I ask this because I would like to cache per build branch, e.g. integration, master, dev branches.


#2

I do layer caching a manual way, and I think per-branch caching would be possible with that. If that is of interest, see this post, and look at the ‘remote image cache’ approach. I dare say that could be modified to include a branch name env var in the cache images.