Skip to content

Mismatch between Dockerfile ARG reference and variable scoping documentation #21041

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

Closed
1 task done
srgoni opened this issue Oct 1, 2024 · 2 comments
Closed
1 task done
Assignees
Labels
area/build Relates to Dockerfiles or docker build command lifecycle/locked

Comments

@srgoni
Copy link

srgoni commented Oct 1, 2024

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

The manual page about build variables describes automatic inheritance of ARGs between stages, but this is nowhere mentioned in the Dockerfile reference.

Variable scoping: https://docs.docker.com/build/building/variables/#scoping

Once a build argument is declared or consumed in a stage, it's automatically inherited by child stages.

Dockerfile reference: https://docs.docker.com/reference/dockerfile/#scope

An ARG instruction goes out of scope at the end of the build stage where it was defined. To use an argument in multiple stages, each stage must include the ARG instruction.

This can lead to confusion and unexpected behavior when relying on ARGs being scrubbed between stages.

Location

https://docs.docker.com/reference/dockerfile/#scope

Suggestion

Since the behavior described in the build variable manual matches what docker build does, it should also be mentioned in the Dockerfile reference.

@srgoni srgoni added the status/triage Needs triage label Oct 1, 2024
@dvdksn dvdksn added area/build Relates to Dockerfiles or docker build command and removed status/triage Needs triage labels Oct 2, 2024
@dvdksn dvdksn self-assigned this Oct 2, 2024
@dvdksn
Copy link
Contributor

dvdksn commented Oct 10, 2024

Thanks for reporting, the fix has been merged upstream, and will be released with the next BuildKit release 👍🏻

@dvdksn dvdksn closed this as completed Oct 10, 2024
@docker-robot
Copy link

docker-robot bot commented Nov 9, 2024

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked

@docker-robot docker-robot bot locked and limited conversation to collaborators Nov 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/build Relates to Dockerfiles or docker build command lifecycle/locked
Projects
None yet
Development

No branches or pull requests

2 participants