File tree Expand file tree Collapse file tree
content/manuals/build/cache Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,13 +116,16 @@ instruction in your Dockerfile:
116116
117117``` dockerfile
118118FROM golang:latest
119- WORKDIR /app
119+ WORKDIR /build
120120RUN --mount=type=bind,target=. go build -o /app/hello
121121```
122122
123- In this example, the current directory is mounted into the build container
124- before the ` go build ` command gets executed. The source code is available in
125- the build container for the duration of that ` RUN ` instruction. When the
123+ In this example, the current directory is mounted into the build container at
124+ ` /build ` before the ` go build ` command gets executed. The build output is
125+ written to ` /app/hello ` , which is outside the mount point. This distinction is
126+ important: the build output must be written outside the bind mount target,
127+ since the mount is read-only by default. The source code is available in the
128+ build container for the duration of that ` RUN ` instruction. When the
126129instruction is done executing, the mounted files are not persisted in the final
127130image, or in the build cache. Only the output of the ` go build ` command
128131remains.
You can’t perform that action at this time.
0 commit comments