{"id":18135,"date":"2019-12-09T16:32:57","date_gmt":"2019-12-10T00:32:57","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=18135"},"modified":"2019-12-10T16:42:44","modified_gmt":"2019-12-11T00:42:44","slug":"improvements-in-windows-powershell-container-images","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/improvements-in-windows-powershell-container-images\/","title":{"rendered":"Improvements in Windows PowerShell Container Images"},"content":{"rendered":"<div class=\"markdown-body\">\n<p>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.<\/p>\n<h2><a id=\"user-content-how-did-the-server-core-images-get-over-40-smaller\" class=\"anchor\" href=\"#how-did-the-server-core-images-get-over-40-smaller\" aria-hidden=\"true\"><\/a>How did the Server Core images get over 40% smaller?<\/h2>\n<p>Traditionally, Windows 10 and Windows Server have always included a set of .NET native binaries that were pre-compiled using the <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/framework\/tools\/ngen-exe-native-image-generator\" rel=\"nofollow\">Native Image Generator tool (Ngen.exe)<\/a>. 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).<\/p>\n<p>For more details, check out corresponding blogs published by the <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/?p=25648\" rel=\"nofollow\">.NET team <\/a>and the <a href=\"https:\/\/techcommunity.microsoft.com\/t5\/Containers\/Making-Windows-Server-Core-Containers-40-Smaller\/ba-p\/1058874\" rel=\"nofollow\">Windows Server team<\/a>.<\/p>\n<h2><a id=\"user-content-what-does-this-mean-for-me-as-a-powershell-user\" class=\"anchor\" href=\"#what-does-this-mean-for-me-as-a-powershell-user\" aria-hidden=\"true\"><\/a>What does this mean for me as a PowerShell user?<\/h2>\n<p>If you depend on Windows Server container images for usage of Windows PowerShell, and you value performance, you should switch from the <a href=\"https:\/\/hub.docker.com\/_\/microsoft-windows-servercore\" rel=\"nofollow\">windows\/servercore <\/a>images to the <a href=\"https:\/\/hub.docker.com\/_\/microsoft-dotnet-framework-runtime\" rel=\"nofollow\">dotnet\/framework\/runtime<\/a> images. The latter are specifically optimized for .NET Framework workloads like Windows PowerShell.<\/p>\n<p>And in fact, switching to the new <code>dotnet\/framework\/runtime<\/code> images will actually provide a greater benefit to startup performance even over the old <code>windows\/servercore<\/code> images. When running <code>Measure-Command { docker run --rm &lt;image&gt; powershell -c \"echo 1\" }<\/code> on a Windows box, observe the following differences:<\/p>\n<table>\n<thead>\n<tr>\n<th><code>windows\/servercore:1903<\/code><\/th>\n<th><code>windows\/servercore\/insider:10.0.19023.1<\/code><\/th>\n<th><code>dotnet\/framework\/runtime:4.8-20191008-windowsservercore-1903<\/code><\/th>\n<th><a href=\"https:\/\/github.com\/microsoft\/dotnet-framework-docker\/blob\/windowserver-2004\/4.8\/runtime\/windowsservercore-2004\/Dockerfile\"><code>dotnet\/framework\/runtime:4.8-windowsservercore-2004<\/code><\/a><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>7.34 sec<\/td>\n<td>5.41 sec<\/td>\n<td>6.8 sec<\/td>\n<td>3.76 sec<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h2><a id=\"user-content-what-if-im-using-powershell-core-instead-of-windows-powershell-in-my-containers\" class=\"anchor\" href=\"#what-if-im-using-powershell-core-instead-of-windows-powershell-in-my-containers\" aria-hidden=\"true\"><\/a>What if I&#8217;m using PowerShell Core instead of Windows PowerShell in my containers?<\/h2>\n<p>If have already moved your workloads from Windows PowerShell to PowerShell Core, you should continue to use the <code>windowsservercore<\/code> images from <a href=\"https:\/\/hub.docker.com\/_\/microsoft-powershell\" rel=\"nofollow\">microsoft\/powershell<\/a>, and when the Windows Server reductions graduate from Insiders you&#8217;ll simply enjoy the benefit of smaller image sizes.<\/p>\n<h2><a id=\"user-content-thats-it\" class=\"anchor\" href=\"#thats-it\" aria-hidden=\"true\"><\/a>That&#8217;s it!<\/h2>\n<p>Thanks to everyone leveraging PowerShell in Docker containers! And make sure to file any issues you have in our <a href=\"https:\/\/github.com\/powershell\/powershell-docker\">powershell-docker repository<\/a>.<\/p>\n<p>Thanks,\nJoey Aiello\nProgram Manager, PowerShell<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":657,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-18135","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/657"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=18135"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18135\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=18135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=18135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=18135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}