Windows-Containers icon indicating copy to clipboard operation
Windows-Containers copied to clipboard

Feature Request: Merge PATH env from both configs and registry hive

Open profnandaa opened this issue 9 months ago • 3 comments

This is a request carried over from this issue - https://github.com/moby/buildkit/issues/5445

Windows primarily gets the PATH environment variable from the registry. However, when the PATH is set in the image config, this will take precedence.

The problem arises with cases of installers and use of setx where the PATH in the registry is modified but the PATH in the config isn’t and the two copies slowly start diverging.

Linux on the other hand, has something that closely resembles what the registry hive does, where variables can be stored in file and loaded either manually or automatically when running the script. However, the advantage on the Linux end is that this PATH variable for instance gets merged basically by string interpolation. For instance if the PATH was set in the image:

ENV PATH="$PATH:/my/path"

And then if you have a script modifying the path:

export PATH=$PATH:/my/other/path

You end up having both /my/path and /my/other/path in the PATH.

NOTE: during container building, only the PATH set in the config is taken into consideration, unless you explicitly load the other PATH from script. If the PATH is set in say a .bashrc script, this will be automatically loaded when running in interactive bash shell.

The request: if Windows could consider (1) setting a default PATH config in the base images and (2) merging both PATH variable from config and registry during container run. For backward compatibility, this will need to be opt-in.

profnandaa avatar Apr 08 '25 08:04 profnandaa

Thank you for creating an Issue. Please note that GitHub is not an official channel for Microsoft support requests. To create an official support request, please open a ticket here. Microsoft and the GitHub Community strive to provide a best effort in answering questions and supporting Issues on GitHub.

github-actions[bot] avatar Apr 08 '25 08:04 github-actions[bot]

This issue has been open for 90 days with no updates. no assignees, please provide an update or close this issue.

This issue has been open for 90 days with no updates. no assignees, please provide an update or close this issue.