Using Windows PowerShell commands in a DockerFile to set up Windows Containers (Docker standard based)
This content is an excerpt from the eBook, Containerized Docker Application Lifecycle with Microsoft Platform and Tools, available on .NET Docs or as a free downloadable PDF that can be read offline.
With Windows Containers, you can convert your existing Windows applications to Docker images and deploy them with the same tools as the rest of the Docker ecosystem.
To use Windows Containers, you just need to write Windows PowerShell commands in the DockerFile, as demonstrated in the following example:
FROM mcr.microsoft.com/windows/servercore:ltsc2019 LABEL Description="IIS" Vendor="Microsoft" Version="10" RUN powershell Get-WindowsFeature web-server RUN powershell Install-windowsfeature web-server RUN powershell add-windowsfeature web-asp-net45 CMD [ "ping", "localhost", "-t" ]
In this case, we're using Windows PowerShell to install a Windows Server Core base image as well as IIS.
In a similar way, you also could use Windows PowerShell commands to set up additional components like the traditional ASP.NET 4.x and .NET Framework 4.6 or any other Windows software, as shown here:
RUN powershell add-windowsfeature web-asp-net45
Submit and view feedback for