buildx: "sending tarball" takes a long time even when the image already exists
When I build an image which already exists (because of a previous build on the same engine with 100% cache hit), the builder still spends a lot of time in “sending tarball”. This causes a noticeable delay in the build. Perhaps this delay could be optimized away in the case of 100% cache hit?
For example, when building a 1.84GB image with 51 layers, the entire build is 9s, of which 8s is in “sending tarball” (see output below).
It would be awesome if fully cached builds returned at near-interactive speed!
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.53kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:la 1.0s
=> [1/51] FROM docker.io/library/alpine@sha256:6a92cd1fcdc8 0.0s
=> => resolve docker.io/library/alpine@sha256:6a92cd1fcdc8d 0.0s
=> CACHED [2/51] RUN apk update 0.0s
=> CACHED [3/51] RUN apk add openssh 0.0s
=> CACHED [4/51] RUN apk add bash 0.0s
=> CACHED [5/51] RUN apk add bind-tools 0.0s
=> CACHED [6/51] RUN apk add curl 0.0s
=> CACHED [7/51] RUN apk add docker 0.0s
=> CACHED [8/51] RUN apk add g++ 0.0s
=> CACHED [9/51] RUN apk add gcc 0.0s
=> CACHED [10/51] RUN apk add git 0.0s
=> CACHED [11/51] RUN apk add git-perl 0.0s
=> CACHED [12/51] RUN apk add make 0.0s
=> CACHED [13/51] RUN apk add python 0.0s
=> CACHED [14/51] RUN apk add openssl-dev 0.0s
=> CACHED [15/51] RUN apk add vim 0.0s
=> CACHED [16/51] RUN apk add py-pip 0.0s
=> CACHED [17/51] RUN apk add file 0.0s
=> CACHED [18/51] RUN apk add groff 0.0s
=> CACHED [19/51] RUN apk add jq 0.0s
=> CACHED [20/51] RUN apk add man 0.0s
=> CACHED [21/51] RUN cd /tmp && git clone https://github.c 0.0s
=> CACHED [22/51] RUN apk add go 0.0s
=> CACHED [23/51] RUN apk add coreutils 0.0s
=> CACHED [24/51] RUN apk add python2-dev 0.0s
=> CACHED [25/51] RUN apk add python3-dev 0.0s
=> CACHED [26/51] RUN apk add tar 0.0s
=> CACHED [27/51] RUN apk add vim 0.0s
=> CACHED [28/51] RUN apk add rsync 0.0s
=> CACHED [29/51] RUN apk add less 0.0s
=> CACHED [30/51] RUN pip install awscli 0.0s
=> CACHED [31/51] RUN curl --silent --location "https://git 0.0s
=> CACHED [32/51] RUN curl https://dl.google.com/dl/cloudsd 0.0s
=> CACHED [33/51] RUN curl -L -o /usr/local/bin/kubectl htt 0.0s
=> CACHED [34/51] RUN curl -L -o /usr/local/bin/kustomize 0.0s
=> CACHED [35/51] RUN apk add ruby 0.0s
=> CACHED [36/51] RUN apk add ruby-dev 0.0s
=> CACHED [37/51] RUN gem install bigdecimal --no-ri --no-r 0.0s
=> CACHED [38/51] RUN gem install kubernetes-deploy --no-ri 0.0s
=> CACHED [39/51] RUN apk add npm 0.0s
=> CACHED [40/51] RUN npm config set unsafe-perm true 0.0s
=> CACHED [41/51] RUN npm install -g yarn 0.0s
=> CACHED [42/51] RUN npm install -g netlify-cli 0.0s
=> CACHED [43/51] RUN apk add libffi-dev 0.0s
=> CACHED [44/51] RUN pip install docker-compose 0.0s
=> CACHED [45/51] RUN apk add mysql-client 0.0s
=> CACHED [46/51] RUN (cd /tmp && curl -L -O https://releas 0.0s
=> CACHED [47/51] RUN apk add shadow sudo 0.0s
=> CACHED [48/51] RUN echo '%wheel ALL=(ALL) NOPASSWD: ALL' 0.0s
=> CACHED [49/51] RUN useradd -G docker,wheel -m -s /bin/ba 0.0s
=> CACHED [50/51] RUN groupmod -o -g 999 docker 0.0s
=> CACHED [51/51] WORKDIR /home/sh 0.0s
=> exporting to oci image format 8.8s
=> => exporting layers 0.3s
=> => exporting manifest sha256:69088589c4e63094e51ae0e34e6 0.0s
=> => exporting config sha256:65db1e1d42a26452307b43bc5c683 0.0s
=> => sending tarball 8.3s
=> importing to docker 0.1s
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 31
- Comments: 16 (3 by maintainers)
@tonistiigi a-ha! that was it. At some point I used
docker buildx create --useand that overwrote the default builder with the Docker driver. Doingdocker buildx lsto find the builder with the Docker driver and thendocker buildx use --default builder_namefixed it for me! No more sending tarball step.In my docker-compose project I’m getting “sending tarball” times of almost 2 minutes, when the entire build is cached. Makes the development experience so painful that I’m considering setting up the services outside of Docker to avoid this.
Our use case also suffers from the time it takes to export to OCI image format/sending tarball.
We end up sticking to
DOCKER_BUILDKIT:Instead of using
buildx:“Sending tarball” means you are running the build inside a container(or k8s or remote instance). While these are powerful modes (eg. for multi-platform) if you want to run the image you just built with local Docker, it needs to be transferred to Docker first. If your workflow is to build and then run in Docker all the time, then you should build with a Docker driver on buildx, because that driver does not have the “sending tarball” phase to make the result available as local Docker image.
You can read more about the drivers at https://github.com/docker/buildx/blob/master/docs/manuals/drivers/index.md
Latest proposal for speeding up the loading phase for other drivers https://github.com/moby/moby/issues/44369
I would like to add a data point and a reproducible example for this problem.
DockerfileCreating a builder with
docker-containerdriver:Building a bunch of big images with
buildx-default:Same but with default builder:
That is a rather dramatic slow-down, especially when building many similar images. As far as I understand all this time is spent on serializing and deserializing data. Even if there’s a hacky half-backed solution like an opt-in flag it would certainly be nice to have a way to optimize this
Something’s off here…
/update: a restart of Docker Desktop solved the problem
@tonistiigi But that will mean the user foregoes the advantages of the other build drivers. The issue is with the performance on sending tarballs.
Yes I agree, an opt-in flag would be best. Thanks.
There should theoretically be a way to do it even for partial matches. A problem though is that there is no guarantee that the image is still in docker when the build finishes up. And if it is deleted before build completes you could get an error(on tag or on uploading layer on partial matches). So maybe needs an opt-in with a flag(at least until there isn’t a special incremental load endpoint in the docker api).