Reusing the cache from a `RUN –mount=type=cache` docker build

I’m using the new experimental docker buildkit syntax to do a multistage build, as so:


RUN --mount=type=cache,target=/home/build/.build-cache,gid=1000,uid=1001 ./build


DOCKER_BUILDKIT=1 docker build .

Works great locally. On CI I get a new docker environment every time, so no caching.

I can export and import files into the env, but I don’t know where the cache is located. Any ideas?

Or should I be exporting/importing the cache via some docker command? I’ve read and but it’s not clear to me which is buildkit specific, which docker specific or if either really applies to this cache mounted into the Dockerfile RUN command.

Source: StackOverflow