Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistencies in RUN mount options parsing/handling #4912

Closed
TyIsI opened this issue May 10, 2024 · 5 comments · Fixed by #5241
Closed

Inconsistencies in RUN mount options parsing/handling #4912

TyIsI opened this issue May 10, 2024 · 5 comments · Fixed by #5241

Comments

@TyIsI
Copy link

TyIsI commented May 10, 2024

While working on a JS/TS Dockerfile generator, I came across some inconsistencies in how the RUN mount options are being parsed/handled.

I just opened an issue for the documentation, but checking the sources, it looks like this might be more source related.

Examples:

## Works with all options that are not listed as supported
RUN --mount=type=tmpfs,target=/cache,size=1024,ro,readonly,rw,readwrite /bin/ls -asl /cache
## Not listed as supported, but pulls from registry
## ERROR [internal] load metadata for docker.io/library/nonexistent:latest
RUN --mount=type=tmpfs,target=/cache,size=1024,from=nonexistent /bin/ls -asl /cache
## Shows directories in root, documentation says from=<stage>, but happily loads image
RUN --mount=type=cache,target=/cache,from=alpine:3,source=/ /bin/ls -asl /cache

I'm not sure if I'm proficient enough in Go to actually come up with a good solution for this and I couldn't find any specs for what the correct behaviour should be, but I believe that the problem lies in parseMount in commands_runmount.go

Happy weekend!

@tonistiigi
Copy link
Member

documentation says from=, but happily loads image

from= takes the same argument as FROM <base> or COPY --from=<stage>. It can be named build context, named stage or image name, in that order or preference.

@TyIsI
Copy link
Author

TyIsI commented Aug 8, 2024

So this should be updated in the documentation, correct?

@tonistiigi
Copy link
Member

I believe this is documented but maybe not in all places @dvdksn

@dvdksn
Copy link
Collaborator

dvdksn commented Aug 12, 2024

I guess we could clarify here, too, that from takes a named context, image ref, or stage name. We do it in a lot of places but not here it seems.

@dvdksn
Copy link
Collaborator

dvdksn commented Aug 12, 2024

I don't suppose tmpfs should support from @tonistiigi and should error ?

## ERROR [internal] load metadata for docker.io/library/nonexistent:latest
RUN --mount=type=tmpfs,target=/cache,size=1024,from=nonexistent /bin/ls -asl /cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants