Skip to content

Commit b71533f

Browse files
authored
Wsl refresh (#24377)
<!--Delete sections as needed --> ## Description Fixes #24367 and does a small tidy ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review
1 parent 13a1e44 commit b71533f

3 files changed

Lines changed: 45 additions & 27 deletions

File tree

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
11
---
2-
title: Best practices
2+
linkTitle: Best practices
3+
title: WSL 2 best practices for Docker Desktop on Windows
34
description: Best practices for using Docker Desktop with WSL 2
4-
keywords: wsl, docker desktop, best practices
5+
keywords: wsl 2, docker desktop, best practices, Windows Subsystem for Linux, Docker Desktop Windows performance
56
tags: [Best practices]
67
aliases:
78
- /desktop/wsl/best-practices/
89
---
910

10-
- Always use the latest version of WSL. At a minimum you must use WSL version 2.1.5, otherwise Docker Desktop may not work as expected. Testing, development, and documentation is based on the newest kernel versions. Older versions of WSL can cause:
11-
- Docker Desktop to hang periodically or when upgrading
12-
- Deployment via SCCM to fail
13-
- The `vmmem.exe` to consume all memory
14-
- Network filter policies to be applied globally, not to specific objects
15-
- GPU failures with containers
11+
This page covers recommendations when running Docker Desktop on Windows using WSL 2, including version requirements and file system performance.
1612

17-
- To get the best out of the file system performance when bind-mounting files, it's recommended that you store source code and other data that is bind-mounted into Linux containers. For instance, use `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](https://learn.microsoft.com/en-us/windows/wsl/compare-versions) from Microsoft.
18-
- Linux containers only receive file change events, “inotify events”, if the original files are stored in the Linux filesystem. For example, some web development workflows rely on inotify events for automatic reloading when files have changed.
19-
- Performance is much higher when files are bind-mounted from the Linux filesystem, rather than remoted from the Windows host. Therefore avoid `docker run -v /mnt/c/users:/users,` where `/mnt/c` is mounted from Windows.
20-
- Instead, from a Linux shell use a command like `docker run -v ~/my-project:/sources <my-image>` where `~` is expanded by the Linux shell to `$HOME`.
13+
## Keep WSL up to date
2114

22-
- If you have concerns about the size of the `docker-desktop-data` distribution, take a look at the [WSL tooling built into Windows](https://learn.microsoft.com/en-us/windows/wsl/disk-space).
23-
- Installations of Docker Desktop version 4.30 and later no longer rely on the `docker-desktop-data` distribution; instead Docker Desktop creates and manages its own virtual hard disk (VHDX) for storage. (note, however, that Docker Desktop keeps using the `docker-desktop-data` distribution if it was already created by an earlier version of the software).
24-
- Starting from version 4.34 and later, Docker Desktop automatically manages the size of the managed VHDX and returns unused space to the operating system.
15+
Always use the latest version of WSL.
2516

26-
- If you have concerns about CPU or memory usage, you can configure limits on the memory, CPU, and swap size allocated to the [WSL 2 utility VM](https://learn.microsoft.com/en-us/windows/wsl/wsl-config#global-configuration-options-with-wslconfig).
17+
At a minimum you must use WSL version 2.1.5, otherwise Docker Desktop may not work as expected. Testing, development, and documentation is based on the newest kernel versions. Older versions of WSL can cause:
18+
- Docker Desktop to hang periodically or when upgrading
19+
- Deployment via SCCM to fail
20+
- The `vmmem.exe` to consume all memory
21+
- Network filter policies to be applied globally, not to specific objects
22+
- GPU failures with containers
23+
24+
## Optimise file system performance with bind mounts
25+
26+
To get the best out of the file system performance when bind-mounting files, store source code and other data that is bind-mounted into Linux containers. For instance, use `docker run -v <host-path>:<container-path>` in the Linux file system, rather than the Windows file system. You can also refer to [Microsoft's recommendation](https://learn.microsoft.com/en-us/windows/wsl/compare-versions).
27+
28+
Linux containers only receive file change events, “inotify events”, if the original files are stored in the Linux filesystem. For example, some web development workflows rely on inotify events for automatic reloading when files have changed.
29+
30+
Performance is much higher when files are bind-mounted from the Linux filesystem, rather than accessed from the Windows host filesystem. Therefore avoid `docker run -v /mnt/c/users:/users` where `/mnt/c` is mounted from Windows.
31+
32+
Instead, from a Linux shell use a command like `docker run -v ~/my-project:/sources <my-image>` where `~` is expanded by the Linux shell to `$HOME`.
33+
34+
## Limit CPU and memory usage
35+
36+
If you have concerns about CPU or memory usage, configure limits on the memory, CPU, and swap size allocated to the [WSL 2 utility VM](https://learn.microsoft.com/en-us/windows/wsl/wsl-config#global-configuration-options-with-wslconfig).

content/manuals/desktop/features/wsl/custom-kernels.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
---
2+
linkTitle: Custom kernels
23
title: Custom kernels on WSL
34
description: Using custom kernels with Docker Desktop on WSL 2
45
keywords: wsl, docker desktop, custom kernel
56
tags: [Best practices, troubleshooting]
67
---
78

8-
Docker Desktop depends on several kernel features built into the default
9-
WSL 2 Linux kernel distributed by Microsoft. Consequently, using a
10-
custom kernel with Docker Desktop on WSL 2 is not officially supported
9+
> [!WARNING]
10+
>
11+
> Using a custom kernel with Docker Desktop on WSL 2 is not officially supported
1112
and may cause issues with Docker Desktop startup or operation.
1213

14+
Docker Desktop depends on several kernel features built into the default
15+
WSL 2 Linux kernel distributed by Microsoft.
16+
1317
However, in some cases it may be necessary
1418
to run custom kernels; Docker Desktop does not block their use, and
1519
some users have reported success using them.
1620

17-
If you choose to use a custom kernel, it is recommended you start
21+
## Recommendations if you must use a custom kernel
22+
23+
If you choose to use a custom kernel, start
1824
from the kernel tree distributed by Microsoft from their [official
1925
repository](https://github.com/microsoft/WSL2-Linux-Kernel) and then add
2026
the features you need on top of that.
2127

22-
It's also recommended that you:
28+
Also:
2329
- Use the same kernel version as the one distributed by the latest WSL2
2430
release. You can find the version by running `wsl.exe --system uname -r`
2531
in a terminal.
26-
- Start from the default kernel configuration as provided by Microsoft
27-
from their [repository](https://github.com/microsoft/WSL2-Linux-Kernel)
28-
and add the features you need on top of that.
2932
- Make sure that your kernel build environment includes `pahole` and
3033
its version is properly reflected in the corresponding kernel config
3134
(`CONFIG_PAHOLE_VERSION`).

content/manuals/desktop/features/wsl/use-wsl.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
---
2-
title: Use WSL
2+
linkTitle: Use WSL
3+
title: Develop with Docker Desktop using WSL 2 on Windows
34
description: How to develop with Docker and WSL 2 and understand GPU support for WSL
45
keywords: wsl, wsl 2, develop, docker desktop, windows
56
aliases:
67
- /desktop/wsl/use-wsl/
78
---
89

9-
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 turned on the WSL 2 feature on Docker Desktop, you can start working with your code inside the Linux distribution and ideally with your IDE still in Windows. This workflow is straightforward if you are using [VS Code](https://code.visualstudio.com/download).
10+
The following section describes how to start developing your applications using Docker and WSL 2.
11+
12+
For the best development experience, store your code inside your default Linux distribution. After you have turned on the WSL 2 feature on Docker Desktop, you can start working with your code inside the Linux distribution and ideally with your IDE still in Windows. This workflow is straightforward if you are using [VS Code](https://code.visualstudio.com/download).
1013

1114
## Develop with Docker and WSL 2
1215

13-
1. Open VS Code and install the [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension. This extension lets you work with a remote server in the Linux distribution and your IDE client still on Windows.
16+
Before you begin, make sure you have enabled WSL 2 integration in Docker Desktop under **Settings** > **Resources** > **WSL Integration**.
17+
18+
1. Open VS Code and install the [WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension. This extension lets you work with a remote server in the Linux distribution and your IDE client still on Windows.
1419
2. Open your terminal and type:
1520

1621
```console

0 commit comments

Comments
 (0)