How to avoid transferring everything as build context

Oh now I get you …

Currently this “effect” is by design → Docker docs: Build with PATH

BUT … I just stumbled over some stackoverfolw post that might solve the issue → build context for docker image very large - Stack Overflow

I’ve tried it myself:

export DOCKER_BUILDKIT=1
docker build -t test:0.3 .
[+] Building 0.5s (8/8) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 145B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for Docker 0.0s
=> CACHED [1/3] FROM Docker 0.0s
=> [2/3] RUN mkdir /var/testdir 0.4s
=> [internal] load build context 0.0s
=> => transferring context: 622B 0.0s
=> [3/3] COPY testdir/dir3/myZipfile.zip /var/testdir 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:a69f603d533eda88b2969a36022d9249f94d5bf61dd39d5260fbda30d3e381ef 0.0s
=> => naming to Docker

… works !

root@deimos:/data/docker/test# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test 0.3 a69f603d533e 14 seconds ago 73.9MB