- Hands-On Kubernetes on Windows
- Piotr Tylenda
- 329字
- 2021-06-24 16:53:58
Running LCOW containers
By default, Docker Desktop for Windows hosts Linux containers using MobyLinuxVM, which provides a minimal, fully-functional environment for hosting Linux containers. This approach is meant only for development and testing purposes as it is not available on Windows Server. Windows Server currently has experimental support for LCOW and it is also possible to enable this feature in Docker Desktop.
To enable LCOW support in Docker Desktop, you have to enable experimental features in the Docker Daemon. Let's take a look:
- Open the Docker Desktop tray icon and select Settings.
- Navigate to the Daemon tab.
- Enable the Experimental features checkbox:
- Apply the changes. Docker Desktop will restart.
Open PowerShell and create a container that uses Linux as the base image by providing the --platform=linux parameter to docker run. In this example, we're creating a busybox container in interactive mode and starting a Bourne shell:
docker run --rm -it --platform=linux busybox /bin/sh
After the container is started, the Bourne shell prompt will appear (/ #). Now, you can verify that you are indeed running inside a Linux container by using the uname command, which prints Linux kernel information:
uname -a
The following screenshot shows the output of the preceding command:
In a separate Powershell window, without closing the Bourne shell in the container, execute the docker inspect <containerId> command in order to verify that the container is indeed running using LCOW using Hyper-V isolation:
In this section, you learned how to install Docker Desktop for Windows tooling and how to verify its functionality, including running Linux containers on Windows. In the next section, you will learn how to approach building your first Windows container image with the help of Visual Studio Code.