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

feature request: allow variables in the `RUN --mount=type=bind` values #815

Open
hakanurhan opened this issue Feb 5, 2019 · 6 comments

Comments

Projects
None yet
5 participants
@hakanurhan
Copy link

commented Feb 5, 2019

When I define an argument (ARG) or an environment variable (ENV) and then try to use it in the RUN --mount=type=bind,... command, I don't get the mount working.

How to reproduce:
Docker version:

$ docker version
Client:
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        4c52b90
 Built:             Wed Jan  9 19:35:01 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:06:30 2019
  OS/Arch:          linux/amd64
  Experimental:     false

I used the following Dockerfile with BUILDKIT=1 and it failed. If I only change ...target=${TEMPORARY_MOUNT_POINT}... to ...target=/tmp-mount..., it works

# syntax = docker/dockerfile:experimental
FROM ubuntu:14.04.5
ARG TEMPORARY_MOUNT_POINT=/tmp-mount
RUN --mount=type=bind,source=./,target=${TEMPORARY_MOUNT_POINT} \
        ls ${TEMPORARY_MOUNT_POINT}

I also tried using ENV instead of the ARG 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

@hakanurhan hakanurhan changed the title Using variables in the RUN --mount=type=bind command Using variables fails in the RUN --mount=type=bind command Feb 5, 2019

@hakanurhan hakanurhan changed the title Using variables fails in the RUN --mount=type=bind command Using variables in the RUN --mount=type=bind command fails Feb 5, 2019

@hakanurhan hakanurhan changed the title Using variables in the RUN --mount=type=bind command fails Using variables in the `RUN --mount=type=bind` command fails Feb 5, 2019

@tonistiigi tonistiigi changed the title Using variables in the `RUN --mount=type=bind` command fails feature request: allow variables in the `RUN --mount=type=bind` values Feb 5, 2019

@simon-weber

This comment has been minimized.

Copy link

commented Feb 13, 2019

I just ran into this. It's interesting that my --progress=plain ... output shows each command identically -- it made me think this was actually supported.

@matshch

This comment has been minimized.

Copy link

commented Mar 18, 2019

The same for me, wasted some time on exploring that variables just doesn't work in mount options, showing nonsense not found: not found error with all variables expanded in command name.

I think there could be two improvements:

  1. Show commands that really executed. So, if variables isn't expanded by buildkit itself, they shouldn't be shown as expanded.
  2. Document that variables can't be used in mount options or implement variable expansion.
@petr-motejlek

This comment has been minimized.

Copy link

commented Apr 1, 2019

+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 :).

@tonistiigi tonistiigi added the bug label Apr 6, 2019

@tonistiigi

This comment has been minimized.

Copy link
Member

commented Apr 6, 2019

Marking the invalid expansion in output as a bug.

Technically we can do the expansion quite easily for the values of the csv, so --mount=type=$type but not so easily for the full strings, eg --mount=$mount because they are evaluated on parse time. Wondering if doing it only for the values might be confusing.

@petr-motejlek

This comment has been minimized.

Copy link

commented Apr 9, 2019

@tonistiigi , thank you. For my current use case, expanding only the leaves (--mount=type=$type,src=$src,dst=$dst would be enough. Not sure about others, though.

Cheers

@matshch

This comment has been minimized.

Copy link

commented Apr 9, 2019

I think expanding only values will be enough for almost everything, and it will be OK if this behavior will be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.