docs icon indicating copy to clipboard operation
docs copied to clipboard

Example given for bind mounts is wrong

Open tg-freigmbh opened this issue 7 months ago • 0 comments

Is this a docs issue?

  • [x] My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

Documentation provides the following Dockerfile

[FROM] golang:latest
[WORKDIR] /app
[RUN] --mount=type=bind,target=. go build -o /app/hello

And claims

Only the output of the go build command remains.

In reality building such a Dockerfile will fail since the output of go build overlaps with the mount. copying /tmp/go-build2793723972/b001/exe/a.out: open /app/hello: read-only file system

Location

https://docs.docker.com/build/cache/optimize/

Suggestion

Probably change [WORKDIR] /build and I suggest also mentions explecitely that using mount binds requires you to strictly create the build output outside of the mount bind, which is usually requires some changes.

tg-freigmbh avatar May 14 '25 14:05 tg-freigmbh