For developers, Windows 10 is a great place to run Docker Windows containers and containerization support was added to the the Windows 10 kernel with the Anniversary Update (note that container images can only be based on Windows Server Core and Nanoserver, not Windows 10). All that’s missing is the Windows-native Docker Engine and some image. Just checking the Task Manager should help people if they should use Docker for Windows or the Docker Toolbox. Current 'Getting Started' says this - Docker for Windows requires 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later) and Microsoft Hyper-V.
It is now possible to run Docker containers on Windows 10 and Windows Server, leveraging Ubuntu as a hosting base. Imagine running your own Linux applications on Windows, using a Linux distribution you are comfortable with: Ubuntu! It is now possible to do so using the power of Docker technology and Hyper-V virtualization on Windows. It relies on the standard install-path of Docker Desktop on Windows 10 systems, if you changed it you have to adjust the path accordingly. You will have no feedback. Just start 'Docker Desktop' from your Start-Menu after you pasted and executed the command from the Run-Dialog. Docker for Windows runs on 64-bit Windows 10 Pro, Enterprise, and Education; 1511 November update, Build 10586 or later. Docker plans to support more versions of Windows 10 in the future. Download Docker. Double-click InstallDocker.msi to run the installer. Follow the Install Wizard: accept the license, authorize the installer. 🔥Free DevOps Course With Course Completion Certificate: https://www.simplilearn.com/learn-devops-basics-skillup?utmcampaign=Skillup-DevOps&utmmedium=Descr.
Estimated reading time: 7 minutes
Windows Subsystem for Linux (WSL) 2 introduces a significant architectural change as it is a full Linux kernel built by Microsoft, allowing Linux containers to run natively without emulation. With Docker Desktop running on WSL 2, users can leverage Linux workspaces and avoid having to maintain both Linux and Windows build scripts. In addition, WSL 2 provides improvements to file system sharing, boot time, and allows access to some cool new features for Docker Desktop users.
Docker Desktop uses the dynamic memory allocation feature in WSL 2 to greatly improve the resource consumption. This means, Docker Desktop only uses the required amount of CPU and memory resources it needs, while enabling CPU and memory-intensive tasks such as building a container to run much faster.
Additionally, with WSL 2, the time required to start a Docker daemon after a cold start is significantly faster. It takes less than 10 seconds to start the Docker daemon when compared to almost a minute in the previous version of Docker Desktop.
Before you install the Docker Desktop WSL 2 backend, you must complete the following steps:
To get the best out of the file system performance when bind-mounting files, we recommend storing source code and other data that is bind-mounted into Linux containers (i.e., with
docker run -v <host-path>:<container-path>) in the Linux file system, rather than the Windows file system. You can also refer to the recommendation from Microsoft.
docker run -v /mnt/c/users:/users(where
/mnt/cis mounted from Windows).
docker run -v ~/my-project:/sources <my-image>where
~is expanded by the Linux shell to
Download Docker Desktop Stable 184.108.40.206 or a later release.
Ensure you have completed the steps described in the Prerequisites section before installing the Docker Desktop Stable 220.127.116.11 release.
From the Docker menu, select Settings > General.
Select the Use WSL 2 based engine check box.
If you have installed Docker Desktop on a system that supports WSL 2, this option will be enabled by default.
Ensure the distribution runs in WSL 2 mode. WSL can run distributions in both v1 or v2 mode.
To check the WSL mode, run:
wsl.exe -l -v
To upgrade your existing Linux distro to v2, run:
wsl.exe --set-version (distro name) 2
To set v2 as the default version for future installations, run:
wsl.exe --set-default-version 2
When Docker Desktop restarts, go to Settings > Resources > WSL Integration.
The Docker-WSL integration will be enabled on your default WSL distribution. To change your default WSL distro, run
wsl --set-default <distro name>.
For example, to set Ubuntu as your default WSL distro, run
wsl --set-default ubuntu.
Optionally, select any additional distributions you would like to enable the Docker-WSL integration on.
The Docker-WSL integration components running in your distro depend on glibc. This can cause issues when running musl-based distros such as Alpine Linux. Alpine users can use the alpine-pkg-glibc package to deploy glibc alongside musl to run the integration.
The following section describes how to start developing your applications using Docker and WSL 2. We recommend that you have your code in your default Linux distribution for the best development experience using Docker and WSL 2. After you have enabled WSL 2 on Docker Desktop, you can start working with your code inside the Linux distro and ideally with your IDE still in Windows. This workflow can be pretty straightforward if you are using VSCode.
Now, you can start working in VSCode remotely. To do this, open your terminal and type:
This opens a new VSCode connected remotely to your default Linux distro which you can check in the bottom corner of the screen.
Alternatively, you can type the name of your default Linux distro in your Start menu, open it, and then run
Starting with Docker Desktop 3.1.0, Docker Desktop supports WSL 2 GPU Paravirtualization (GPU-PV) on NVIDIA GPUs. To enable WSL 2 GPU Paravirtualization, you need:
wsl --updatefrom an elevated commmand prompt
To validate that everything works as expected, run the following command to run a short benchmark on your GPU:
Your feedback is very important to us. Please let us know your feedback by creating an issue in the Docker Desktop for Windows GitHub repository and adding the WSL 2 label.