Improvements in Windows PowerShell Container Images

This post was originally published on this site

Beginning with Windows Server 20H1 Insider builds, Windows Server Core Insider images have been reduced in size from ~2.1 GBs to ~1.1 GBs.

How did the Server Core images get over 40% smaller?

Traditionally, Windows 10 and Windows Server have always included a set of .NET native binaries that were pre-compiled using the Native Image Generator tool (Ngen.exe). This native pre-compilation makes these binaries faster on default installations of the OS, but it also makes the image size grow: managed/IL .NET binaries are typically smaller and slower initially (until JIT compilation happens) than their native counterparts (with another tradeoff being that the latter are not portable between platforms and architectures).

For more details, check out corresponding blogs published by the .NET team and the Windows Server team.

What does this mean for me as a PowerShell user?

If you depend on Windows Server container images for usage of Windows PowerShell, and you value performance, you should switch from the windows/servercore images to the dotnet/framework/runtime images. The latter are specifically optimized for .NET Framework workloads like Windows PowerShell.

And in fact, switching to the new dotnet/framework/runtime images will actually provide a greater benefit to startup performance even over the old windows/servercore images. When running Measure-Command { docker run --rm <image> powershell -c "echo 1" } on a Windows box, observe the following differences:

windows/servercore:1903 windows/servercore/insider:10.0.19023.1 dotnet/framework/runtime:4.8-20191008-windowsservercore-1903 dotnet/framework/runtime:4.8-windowsservercore-2004
7.34 sec 5.41 sec 6.8 sec 3.76 sec

 

What if I’m using PowerShell Core instead of Windows PowerShell in my containers?

If have already moved your workloads from Windows PowerShell to PowerShell Core, you should continue to use the windowsservercore images from microsoft/powershell, and when the Windows Server reductions graduate from Insiders you’ll simply enjoy the benefit of smaller image sizes.

That’s it!

Thanks to everyone leveraging PowerShell in Docker containers! And make sure to file any issues you have in our powershell-docker repository.

Thanks,
Joey Aiello
Program Manager, PowerShell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.