Reputation: 11
Installing Oracle Client and .NET Framework on Windows Nano Server LTSC 2022 for .NET Application Hosting
Background: I have successfully hosted a .NET application on a Windows Server Core LTSC 2022, using the Oracle Client for database communication. However, the Server Core image has a large size (around 6 to 7 GB). Now, I am attempting to achieve the same on a Windows Nano Server LTSC 2022 to reduce the image size. The Nano Server does not have the traditional MSI installer, and installing PowerShell has proven challenging.
Steps Taken on Nano Server:
Base Image Used: I am using the base image mcr.microsoft.com/windows/nanoserver:ltsc2022.
PowerShell Installation Attempt: I tried installing PowerShell using the installation file, but it failed due to the absence of misexec.exe on Nano Server.
WSA Package Installer Issue: Nano Server does not have the traditional MSI installer and comes with WSA Package Installer. However, I couldn't find information on installing packages using WSA on Nano Server.
Copying MSI Installer Files: I attempted to copy MSI installer files and binaries from a Windows Server 2022 system to Nano Server, but it did not work.
Docker Multistage Build Technique: I employed the Docker multistage build technique, referencing servercore:ltsc2022 to create a core image. I installed PowerShell on this image and tried copying the files into Nano Server, but this approach also failed.
Key Questions:
How can I install PowerShell on Nano Server LTSC 2022, given the absence of traditional MSI installers? What is the correct method for installing packages on Nano Server using the WSA Package Installer? Are there alternative approaches or best practices for reducing the image size on Nano Server while maintaining the required components (Oracle Client, .NET Framework 4) for hosting the .NET application? Note: I am looking for a solution that does not involve using IIS on Nano Server, and I need to build the setup from scratch without relying on pre-configured Nano IIS server images.
below is my docker file
FROM mcr.microsoft.com/windows/servercore:ltsc2022
SHELL ["powershell"]
RUN Invoke-WebRequest -Uri https://aka.ms/download-powershell.msi -OutFile powershell.msi; \
Start-Process msiexec.exe -ArgumentList '/i', 'powershell.msi', '/quiet', '/norestart' - NoNewWindow -Wait
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
WORKDIR /NanoServer
COPY --from=0 /Windows/System32/WindowsPowerShell /NanoServer/WindowsPowerShell
RUN cmd /S /C "setx PATH \"%PATH%;C:\NanoServer\WindowsPowerShell\v1.0\""
WORKDIR /app
This also did'not work
could any one please help me on this .
Upvotes: 0
Views: 694
Reputation: 27
The MCR already has ltsc2022 nanoserver and servercore images with powershell. https://mcr.microsoft.com/en-us/artifact/mar/powershell/tags.
In your Dockerfile, include
ENV PATH="C:/Program Files/Powershell;${PATH}"
You can then use pwsh
for powershell.
In fact, if you want to run powershell in your build it would look something like this:
RUN pwsh -Command "Invoke-WebRequest -Uri <SomethingToDownload> -OutFile <SomethingDownloaded>
Upvotes: 0