profile
viewpoint

Ask questionsRUN --mount=type=cache causes the whole build context to be loaded in

We're using buildkit because it drastically reduces the size of the build context that needs to be copied across during builds. However, it looks like RUN --mount=type=cache causes the entire build context to be copied for some reason.

Before:

COPY something /something
WORKDIR /something/
RUN go build
=> [internal] load build context                                                                                                                                                 0.1s  
=> => transferring context: 1.27MB                                                                                                                                               0.0s

After:

COPY something /something
WORKDIR /something/
RUN --mount=type=cache,target=/.cache go build
=> [internal] load build context                                                                                                                                               103.3s  
=> => transferring context: 5.28GB                                                                                                                                             103.3s
...

This is on Windows 10 with experimental features enabled in Docker.

moby/buildkit

Answer questions xkszltl

I even tried the docker-ce nightly (2019-07-19), and that seems working, but not always. There were several times where I got failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: frontend grpc server closed unexpectedly image

useful!

Related questions

Documentation claims that --mount works with 18.06 hot 1
rootless image didn't work on OKD (OpenShift) 3.11 hot 1
php build fails when cache is enabled hot 1
Documentation claims that --mount works with 18.06 hot 1
Cannot build from local image with buildctl (OCI Worker) hot 1
Image id shown as missing with docker history hot 1
Attempt to mount an overlay layer that is already in-use hot 1
Image id shown as missing with docker history hot 1
helper image - encountered unknown type ; children may not be fetched hot 1
Cannot build from local image with buildctl (OCI Worker) hot 1
Image id shown as missing with docker history hot 1
rootless image didn't work on OKD (OpenShift) 3.11 hot 1
Cannot build from local image with buildctl (OCI Worker) hot 1
ssh agent only forwarded from keys on Windows hot 1
Documentation claims that --mount works with 18.06 hot 1
Github User Rank List