Interview Prep/Docker/Dockerfile Instructions & Builds

What does `--mount=type=bind` do in `RUN`?

AdvancedConceptDockerfile Instructions & Builds
Answer

It mounts files from the build context or another stage read-only into a RUN step without copying them into a layer. Good for using a lockfile or source only during a build step.

RUN --mount=type=bind,source=go.mod,target=go.mod \
    --mount=type=bind,source=go.sum,target=go.sum \
    go mod download
All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds