-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feature request: allow variables in the RUN --mount=type=bind
values
#815
Comments
RUN --mount=type=bind
command fails
RUN --mount=type=bind
command failsRUN --mount=type=bind
values
I just ran into this. It's interesting that my |
The same for me, wasted some time on exploring that variables just doesn't work in mount options, showing nonsense I think there could be two improvements:
|
+1 I too hate the fact that the full command line is printed out expanded, while it would appear that internally it's really not expanded, or perhaps expanded at a different stage of the build. It is really confusing to users. I would like the expansions to be supported, but if they cannot, at least make the printed out commands show the variable names to make it easier for debug :). |
Marking the invalid expansion in output as a bug. Technically we can do the expansion quite easily for the values of the csv, so |
@tonistiigi , thank you. For my current use case, expanding only the leaves ( Cheers |
I think expanding only values will be enough for almost everything, and it will be OK if this behavior will be documented. |
The cache `id` was not set correctly, leading to various undefined behaviors as the overlay volume was reused across parallel builds. Adding it back is gated on the ability to use variables this way: moby/buildkit#815 Signed-off-by: Ben Cressey <bcressey@amazon.com>
Expanding values would cover almost all use cases, I think. In my case, I have multiple projects that need separate caches -- and because these builds are automated, I need to be able to pass in a couple of strings to determine which cache is used at build time. I can work around my particular issue by creating subdirectories off of the cache target based on the passed-in build args, but this is far from ideal. |
while we're at it, lets make sure when we implement this that we implement it for all flag values. i just had to workaround |
Can't make it work for the |
Can agree that expanding only the values would cover our use case. What's the status of this? |
Can you provide the "single-line" stage as an example? Not that I need to do that, but I wonder what you meant by it :). |
I'd like to express my support for allowing variables in |
Hey @tonistiigi, can I take a stab at adding support for this?
WDYT? |
@omermizr Sure. For I'm not sure if the empty value should be an automatic error. There a probably valid cases for that. I'd add another task: Make sure progress output shows replaced variables correctly. Eg. var in csv key should not show up as replaced in progress. Instead of just replacing variables on the |
@omermizr Did you get anywhere with this? |
@tonistiigi Actually yeah, I got it working locally. I still need to do some cleanups and add a few tests and I'll make a PR :) |
Can you put an example of this working? I'm still getting an error when I try to set uid to an arg. Using |
@ayk33 I don't think a new version was released since my contribution. Looks like there's a staging build you can use, but it's probably not a good idea: https://hub.docker.com/r/docker/dockerfile-upstream. |
@omermizr v0.9-rc targeted within a week |
Previously it wasn't possible to use docker ARG values in the `--mount` argument: moby/buildkit#815 This has been fixed, so we can stop the duplication.
What is the status on this? Have to agree that it's frustrating that the command line shows it expanded and the failing is silent... |
@raphaelpreston it looks like you need to start your Dockerfile with a line like
to enable ARG support in |
@findepi The latest is a couple of minor versions ahead and has these changes, so it is safe to say that starting the Dockerfile with
also supports ARG in the I have verified this as well. |
The cache `id` was not set correctly, leading to various undefined behaviors as the overlay volume was reused across parallel builds. Adding it back is gated on the ability to use variables this way: moby/buildkit#815 Signed-off-by: Ben Cressey <bcressey@amazon.com>
When I define an argument (
ARG
) or an environment variable (ENV
) and then try to use it in theRUN --mount=type=bind,...
command, I don't get the mount working.How to reproduce:
Docker version:
I used the following Dockerfile with BUILDKIT=1 and it failed. If I only change
...target=${TEMPORARY_MOUNT_POINT}...
to...target=/tmp-mount...
, it worksI also tried using
ENV
instead of theARG
command, but I had the same results.The failing and non-failing Dockerfile's are attached (I had to add
.txt
extension, they are ordinary Dockerfiles)Dockerfile.fail.txt
Dockerfile.success.txt
The text was updated successfully, but these errors were encountered: