awnion
Docker `RUN --mount=type=bind,target=.` support
Docker officially do this and also it's a common practice:
https://github.com/docker/compose/blob/v2/Dockerfile#L65
https://github.com/docker/buildx/blob/master/Dockerfile#L72
and so on...
Search for
--mount=type=bind
and --mount=.
they are the same.
The point is when you bind you can restrict write (while you copy you lose control) + files stay in the intermediate layer in your local cache like "come on man" 🙂
Also it's faster (especially on Mac with gGRP transport).
That's ok if you don't want to implement it. I get it.
Just add it into documentation plz because it's not obvious at all. The build just breaks while it works locally and looks fine -- the worst type of error 🙂
Also both COPY and --mount=type=bind
can't get access to files outside of the context directory and can't access files mentioned in .dockerignore
.6 replies