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

Allow using variables in COPY --from= #2374

Closed
selurvedu opened this issue Sep 23, 2021 · 1 comment
Closed

Allow using variables in COPY --from= #2374

selurvedu opened this issue Sep 23, 2021 · 1 comment

Comments

@selurvedu
Copy link

Variables defined via ARG can't be used in COPY --from=$ARG /source /target.

Example:

FROM scratch
ARG SOURCE=debian:11
COPY --from=$SOURCE /etc/os-release /target
$ DOCKER_BUILDKIT=1 docker build
...
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to parse stage name "$SOURCE": invalid reference format: repository name must be lowercase

FYI, the variable in a source or target definintion, e.g. COPY --from=debian:11 /etc/os-release /target/$SOURCE, gets expanded correctly both with and without DOCKER_BUILDKIT=1.

May be related to #815.

@tonistiigi
Copy link
Member

Args in --from are currently limited to only args in global scope because using local variables would invalidate the dependency chain between stages. For how to use global args read https://medium.com/@tonistiigi/advanced-multi-stage-build-patterns-6f741b852fae

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

No branches or pull requests

2 participants