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

Cannot set path in Windows 1809 #236

Closed
brianharwell opened this issue Jun 4, 2019 · 12 comments
Closed

Cannot set path in Windows 1809 #236

brianharwell opened this issue Jun 4, 2019 · 12 comments
Assignees

Comments

@brianharwell
Copy link

Steps to reproduce

The following Dockerfile results in an image that either fails to build or does not set the path environment variable...

FROM mcr.microsoft.com/powershell:nanoserver-1809 as runtime
SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# RUN setx Path "C:\foo" -> ERROR: The system cannot find registry path specified.

# RUN setx /M Path "C:\foo" -> ERROR: Access to the registry path is denied.

# RUN [Environment]::SetEnvironmentVariable("Path", "C:\foo", "User") -> Missing ')' in method call.

# RUN [Environment]::SetEnvironmentVariable('Path', 'C:\foo', 'User') -> $env:Path returns C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;

# RUN [Environment]::SetEnvironmentVariable('Path', 'C:\foo', 'Machine') -> Exception calling "SetEnvironmentVariable" with "3" argument(s): "Requested registry access is not allowed."

# RUN $env:Path = 'C:\foo' -> $env:Path returns C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;

Expected behavior

To be able to set the path environment variable

Environment data

Server Version: 18.09.2
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 17763 (17763.1.amd64fre.rs5_release.180914-1434)
Operating System: Windows 10 Enterprise Version 1809 (OS Build 17763.316)
OSType: windows
Architecture: x86_64
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 70
System Time: 2019-06-04T16:59:47.1402861-05:00
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Name Value


PSVersion 6.2.1
PSEdition Core
GitCommitId 6.2.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

@TravisEz13
Copy link
Member

Yes, this is a know issue with the underlying image.
See #231

@TravisEz13
Copy link
Member

Please also see #164 which you JUST commented on

@TravisEz13
Copy link
Member

TravisEz13 commented Jun 4, 2019

In nanoserver 1809, the method used here in the Dockerfile is the only method that will work:
https://github.com/PowerShell/PowerShell-Docker/pull/165/files#diff-27ac98a3293c888d660df1794159c00fR72

ENV PATH="$WindowsPATH;${ProgramFiles}\PowerShell"

@brianharwell
Copy link
Author

Yes and I thought #164 was my issue but when you said it was fixed I realized my issue is different.

@brianharwell
Copy link
Author

Thank you for the workaround

@TravisEz13
Copy link
Member

Another workaround is to use nanoserver-1803.

@TravisEz13
Copy link
Member

#164 was caused by the issue you were hitting. I cannot fix it because it's a nanoserver docker issue. I've been assured that it will be fixed in what should be 1909

@TravisEz13
Copy link
Member

@brianharwell I updated the issue description in #164 to include a note about this. Could you review?

@brianharwell
Copy link
Author

Ok thx! Great seeing you at DockerCon!

@brianharwell
Copy link
Author

@brianharwell I updated the issue description in #164 to include a note about this. Could you review?

Looks good!

@ta32
Copy link

ta32 commented Nov 5, 2020

@TravisEz13 is there a way to set the path without powershell, because powershell was removed from the nanoserver base image?
I tried in 1903 and it didnt work... also 1909

ok i figured out a hack ENV PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PostgreSQL\bin;C:\Program Files\node;"
something like this seems to work

@TravisEz13
Copy link
Member

@ta32 This is off topic. You need to create a windows support ticked for that question.

@PowerShell PowerShell locked as off-topic and limited conversation to collaborators Nov 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants