I am writing a Dockerfile to create a container for OpenJDK using the new, native docker support in Windows 10. This is NOT using docker-toolbox. I would like to set the system path to include the java path, but I can't figure out how. I've tried several variations of the following file, but I can't get the path to set correctly.
FROM nanoserver:latest
RUN powershell -Command "Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;Set-PSRepository -Name PSGallery -InstallationPolicy Trusted;Install-Module PS7Zip;"
ADD https://github.com/ojdkbuild/ojdkbuild/releases/download/1.8.0.91-3/java-1.8.0-openjdk-1.8.0.91-3.b14.windows.x86_64.zip java.zip
RUN setx /M JRE_HOME C:\java-1.8.0-openjdk-1.8.0.91-3.b14.windows.x86_64\jre
RUN setx /M JAVA_HOME C:\java-1.8.0-openjdk-1.8.0.91-3.b14.windows.x86_64
RUN powershell -Command "Expand-7Zip java.zip"
RUN ["powershell", "$env:Path=$env:Path+\";C:\\java-1.8.0-openjdk-1.8.0.91-3.b14.windows.x86_64\\bin\""]
看起来这个 Golang 示例有一个粗暴的方法来做到这一点: https : //github.com/MicrosoftDocs/Virtualization-Documentation/blob/master/windows-container-samples/golang/Dockerfile#L24
Unfortunately, Powershell does not allow modifying the system path variable using that method. The $env:Path
gives read access to the system path, not write. Which means if you change $env:Path
it will only affect your current PS environment.
See this link for a way to make changes to the system path variable: http://codingbee.net/tutorials/powershell/powershell-make-a-permanent-change-to-the-path-environment-variable/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.