deploy with docker does not use layer cache

I’m building and testing a docker image locally then deploying to fly - flyctl deploy.
However the deploy does not use the docker layer cache meaning it takes a long time.
What’s with that?

irrc the default option is to use the remote builder that fly provides for us, which might be the case for not using cache. Does the same happen even when you deploy again/later versions?

The default option is to build locally - the remote builder requires flyctl deploy --remote-only - see the flyctl deploy doc.

Yes, a layer cache is used by flyctl deploy on subsequent builds. The problem is that it does not use the layer cache used by docker build which means the first deploy can be very time-consuming.

makes sense, the default remote-builder option is in fly launch. maybe the --image tag should do the trick.

We actually do use the system Docker layer cache for local builds. There’s some configs where it’s not very effective, though, I think it has something to do with local Docker versions and buildkit settings. Which version of Docker are you running locally?

If you’re on an ARM system (like modern Macbooks), docker build won’t build an x86_64 image. flyctl deploy does. Builds for different architectures don’t share a layer cache.

I’m on Ubuntu 21.10 using system docker - 20.10.7 so pretty vanilla.

Maybe buildkit is the thing - I notice it’s enabled on remote deploys.
I’ll enable it locally and report back.

Yeah, that’s it - need to have buildkit enabled locally for layer caching to work when deploying.

1 Like