不再被系統版本限制的 Windows 11 Docker

| | 0 Comments| 10:09
Categories:

硬體限制很多的 Windows 11 正式版終於正式推出了。一如往常,在初期階段也發現了不少問題,有待後續解決。

而在這次大改版的 Windows 11 裡,個人覺得一個很重要的功能,就是 Windows 11 的 Docker 的 process isolation 相容性大幅改善了

以往在使用 Windows Docker 的時候,很討厭的一點,就是如果想要使用 process isolation 的話,那容器的作業系統版本要和主機的版本完全一致才可以。(以前也抱怨過了…)

比如說,如果電腦是 Windows 10 20H2 的話,那就只能使用以 20H2 為基底的 Docker image,才能用 process isolation 來執行;否則,就只能用 Hyper-V 模式來跑了。

再加上微軟在 base image 的發布上並沒有很積極,所以如果真的有需求要跑 process isolation 的 Windows Docker 容器,往往會需要在 Windows 大版本推出的時候、讓電腦暫停升級、去等微軟釋出對應的新的 base image 才行。

而因為這個狀況而發生最極端的慘案,就出現在 Windows 10 21H1 上…

理論上 Windows 10 21H1 是目前 Windows 10 最新的版本,也已經推出快半年了;但是由於 Windows Server 沒有對應 21H1 的版本(附註),所以微軟也沒有(也不會)釋出 21H1 的 Windows Docker 的 base image…這就導致了 Windows 10 21H1 的使用者,由於缺少對應的 base image,所以完全沒有辦法以 process isolation 的形式來執行 Windows Docker 的容器

這部分相關的討論,可以參考《Should we expect Windows container base images labelled 21H1/10.0.19043.X?》,基本上也是引起許多人的不滿…


而在 WIndows Server 2022 以及 Windows 11,這個問題目前看來應該是可以永遠性的解決了!

微軟在《Windows Server 2022 and beyond for containers》這篇文章中,就有針對這部分做說明。在文中就有提到:

從 Windows Server 2022 開始,使用者將可以在任何組建的 Windows Server 2022 或 Windows 11 上,以 process 或 Hyper-V isolation 的形式、來執行 Windows Server 2022 的 container image
(Starting with Windows Server 2022, customers will be able to run their Windows Server 2022 container images with either process or Hyper-V isolation on any build of Windows Server 2022 or Windows 11.)

也就是說,Windows 11 的使用者以後只要是基於 Windows Server 2022 的 Docker image,都可以不管組件編號、透過 process isolation 來執行容器了~

雖然對於一般沒使用 Windows Docker 的人來說,應該是無感的,但是這個功能對於有需要的人來說,可能也會是 Windows 11 和 Windows 10 一個最大的差異了!

Heresy 也在一台 Windows 11 Insider 的機器(OS 組建是 22471.230)上試了一下,同樣是「mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022」這個 Windows Server 2022 的 Docker image,如果用 Hyper-V 隔離來執行的話,它顯示的 Windows 版本會是 Docker image 的「10.0.20348.230」;但是如果改用 process 隔離來執行的話,他則是會顯示主機的系統版本、也就是「10.0.22471.230」。

而基本上,在 Windows 11 和 Windows Server 2022,微軟應該是針對 kernel 對於整個作業系統的架構有做出調整,所以才能允許這樣的操作。

也因此,在 Windows 11 的電腦上,雖然還是可以用 Hyper-V 隔離來執行以前的 Windows 10 20H2 的 Docker image;不過如果想要用 process 隔離來跑的話,就會出現版本不符合的錯誤了。

他的錯誤訊息是「failure in a Windows system call: The container operating system does not match the host operating system. (0xc0370101)」,基本上就是以往 Windows 10 想以 process 隔離執行不同版本的 Docker image 時的錯誤訊息了。


由於以後 Windows 11 可以用 process 隔離來執行任何 Windows Server 2022 版的 base image,所以就不會出現以往要等新版本 base image、還有自己的 Docker image 要隨著版本更新重建的狀況了~

雖然這點在 Windows 11 來說,應該是件好事,不過在另一方面,對舊有的 Windows 10 電腦就有個糟糕消息了…

那就是 Windows 10 完全不支援 Windows Server 2022 的 Docker image…不要說要建立容器執行了,在 pull image 的階段,就直接跳出來說不相容了… orz

> docker pull mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022
4.8-windowsservercore-ltsc2022: Pulling from dotnet/framework/sdk
a Windows version 10.0.20348-based image is incompatible with a 10.0.19043 host

由於看來 Windows 10 會完全無法執行 Windows Server 2022 的 Docker image,所以看來以後 Windows Docker Image 應該得根據 Windows 10 / 11 來各自建立了…

考量到很多舊電腦應該會沒辦法升級到 Windows 11,到底要不要使用 Windows Server 2022 的 Docker image 可能又會變成一個頭大的問題了。(眼神死


附註:Windows Docker base image 基本上都是基於 Windows Server 來製作的。

Leave a Reply

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *