Requirements: Some old projects need to run on Windows, or the project needs to call some com components to get the results, at this time, we can only build images based on Windows and run Windows-based containers.
About Windows ContainersMicrosoft's official documentation:The hyperlink login is visible.
Windows base image
Microsoft provides several images, called base images, from which you can start building your own container images:
- Windows - Contains the full set of Windows APIs and system services (except for server roles).
- Windows Server - Contains the full suite of Windows APIs and system services.
- Windows Server Core - A smaller image that contains some of the Windows Server APIs - the full .NET Framework. It also includes most, but not all, server roles, such as not including a fax server.
- Nano Server - The smallest Windows Server image, including support for .NET Core APIs and certain server roles.
The image with the suffix name insider is the build, which is actually the same as the versionPreview。
Remember,The Windows container base image is divided into two layers: the RTM layer and the patch layer, which contains the latest security fixes for OS libraries and binaries overlaid on the RTM layer. The patch layer size fluctuates throughout the lifetime of the container image support cycle, increasing or shrinking month by month depending on the incremental change in the binary. When you pull a Windows container base image on a new host, you must pull both layers at the same time.
Introduction to Container Base Images:The hyperlink login is visible. Mirror Hub address:The hyperlink login is visible.
OS requirements
The requirements for Windows container hosts are listed as follows:
- The Windows Containers feature is available in Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows 10 Pro and Enterprise editions (versions 1607 and later), and Windows 11 Pro and Enterprise.
- Hyper-V roles must be installed before running Hyper-V isolation operations.
- The Windows Server container host must install Windows to c:. There is no such limitation if you only deploy Hyper-V isolated containers.
Windows 11 Install Docker Desktop
Download Address:The hyperlink login is visible.
Once installed, set the default container type to Windows container. To switch after the installation is complete, you can use the Docker item in the Windows system taskbar, as shown in the image below:
Containers feature is disabled. Enable it using the PowerShell script (in an administrative PowerShell) and restart your computer before using Docker Desktop:
Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All
If you encounter the above error, run Window Terminal (Windows PowerShell) as an administrator with the following command:
After doing so, you need to restart your computer. Then set the type to Windows container again, and after the switch is successful, as shown in the figure below:
Dockerfile build image
Create a new Dockerfile file with the following contents:
For more Dockerfile examples, please refer to:The hyperlink login is visible.
To build a new image, the command is as follows:
Run containers
Finally, create a container based on the image with the following command:
Try using a browser to access:http://127.0.0.1:5006/, as shown in the figure below:
Successfully access the IIS default site inside the container.
(End)
|