buildx icon indicating copy to clipboard operation
buildx copied to clipboard

Make --load faster

Open kunaltyagi opened this issue 4 years ago • 4 comments

Using --load takes a long time while buildx:

  • loads metadata for base image (acceptable, but takes 5 seconds or so)
  • finds everything in cache (takes 0 seconds)
  • sends tarball (15 seconds)
  • docker imports it (0.1 second since there's no change at all)

Would it be possible for buildx to check if creating the tarball is a necessity or not? Could it use docker inspect <image_tag>? There is a sha256 available for checking

kunaltyagi avatar Jun 01 '21 02:06 kunaltyagi

This would require changes in docker engine load endpoints as well as buildkit's tar exporter(possibly a different exporter and load endpoint altogether).

tonistiigi avatar Jun 01 '21 19:06 tonistiigi

I was hoping to use buildx to speed up local dev builds by pushing to a layer cache from CI and then pulling the layers in locally if necessary. But it seems to me that by using --cache-from=... --load in my local build command, it will re export the layers/image on every invocation, which on a large image can take a long time. I was hoping it would only do the export if it pulls new layers in, not if they haven't changed. Is there any way to get buildx to pull in remote layers and export if necessary, or pass quickly if not?

Edit:

I did manage to get this working! By using the regular docker build instead of buildx and using --cache-from with --build-arg BUILDKIT_INLINE_CACHE=1 as documented here

jaredlockhart avatar Jul 12 '21 22:07 jaredlockhart

I love buildx and won't be going back to the original docker build. But it takes sooooo long to load after buildilng with buildx, quite often taking the majority of the time as the build itself is so quick! This would greatly speed up the overall build since it is now the bottleneck.

pongnguy avatar Nov 22 '23 06:11 pongnguy

https://github.com/moby/moby/issues/44369 is the engine-side requirement for this.

tonistiigi avatar Nov 22 '23 06:11 tonistiigi