-
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
RFC: Removed the default set PATH for Windows environments. #4895
base: master
Are you sure you want to change the base?
RFC: Removed the default set PATH for Windows environments. #4895
Conversation
3e47de5
to
7b1de15
Compare
2e4fe59
to
e2a0a84
Compare
6c0366d
to
113c423
Compare
113c423
to
af8c591
Compare
af8c591
to
1c4cb16
Compare
…ecks whether the path in a Windows container image can be set or not. Signed-off-by: Daniel Githinji <[email protected]>
…s images to set the PATH while running Signed-off-by: Daniel Githinji <[email protected]>
1c4cb16
to
ddb7a7c
Compare
Also see ; |
Hi @thaJeztah -- we've been trying to get some context from the previous PR but was getting lost in the discussions. If you don't mind, able to help with a summary? Esp.
Thanks for TAL. |
allTests = append(allTests, windowsTests...) | ||
} | ||
|
||
func testSetPath(t *testing.T, sb integration.Sandbox) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW this needs to only run on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was therefore proposing this #5445
// ';' character . | ||
const DefaultPathEnvWindows = "c:\\Windows\\System32;c:\\Windows" | ||
// DefaultPathEnvWindows is empty to allow windows to set the PATH when it runs | ||
const DefaultPathEnvWindows = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: so this ensures backward compatibility with classic docker build
, but on the downside, you can't do something like this:
ENV PATH "$PATH;C:\\add\\my\\path"
You end up with PATH=;C:\\add\\my\\path
, and the one coming from the registry is now ignored. We therefore end up with some inconsistencies.
This change is related to this PR: Don't set a default PATH for Windows #3158.
Description:
This change seeks to remove the defaulted Windows image path found in util\system\path.go.
When the PATH is defaulted to a specific value, application files for applications like PowerShell and any other installed application cannot be found/referenced. The reason for this is that Windows saves its environment variables in the registry.
Let's look at some examples to drive this point home.
Example 1: Get access to powershell
I used buildkit to create two images with following dockerfile contents:
When you run this image you get the following result:
Running the image gives the following result:
Example 2: Installing an application or binary
I created an image that has an installed Go binary using the following dockerfile:
Dockerfile:
Image build results:
Image build results:
From Example 2 above, its clear to see how installing binaries/applications where the PATH has a default value ensures that the application can't be accessed from the env path variable, unless its referenced from the specific location that its in installed in.
When the PATH isn't set the installed application path is set in both the registry item as well as path that is available when running the image.
Example 3:
The following examples make use of setx /m command that is specific to Windows to update the path.
Here's the dockerfile that I used:
Image build results:
In this case the setx command does not update the path env variable
Image build results:
Conclusion:
There are several versions of windows containers each with its own use-case. For example servercore(that used in the examples above) is used because it contains powershell whereas images with the .net libraries are used for that particular function. Each of these images have different installed native applications and libraries.
When the PATH is defaulted accessibility to image applications is lost and a lot of manual steps such as using the full path for each application has to be done in order to use them.
Therefore removing the defaulted Windows image path: