In the very first Dockerfile (5.3.1), COPY . . will also copy the target/ directory, which makes the context size for Docker ~10GB on my machine by the time I reach this chapter. This makes the very first docker build command fails with :
Dockerfile:8
--------------------
6 | RUN apt update && apt install lld clang -y
7 |
8 | >>> COPY . .
9 |
10 | RUN cargo build --release
--------------------
ERROR: failed to solve: failed to copy files: copy file range failed: no space left on device
Solution:
Add a .dockerignore file with target/ in it. The context size goes from ~10GB to ~400kB (on failing build: => => transferring context: 10.67GB ; on fixed build: => => transferring context: 407.96kB). Also, transferring the 10GB takes ~75s according to Docker on my machine, whereas transferring the 400kB takes 0.0s. Even if it works, I think it's a no-brainer.
Hope this helps the author and anyone encountering the problem!
Hello,
In the very first Dockerfile (5.3.1),
COPY . .
will also copy thetarget/
directory, which makes the context size for Docker ~10GB on my machine by the time I reach this chapter. This makes the very firstdocker build
command fails with :Solution:
Add a
.dockerignore
file withtarget/
in it. The context size goes from ~10GB to ~400kB (on failing build:=> => transferring context: 10.67GB
; on fixed build:=> => transferring context: 407.96kB
). Also, transferring the 10GB takes ~75s according to Docker on my machine, whereas transferring the 400kB takes 0.0s. Even if it works, I think it's a no-brainer.Hope this helps the author and anyone encountering the problem!