⚠️ Traduction non officielle - Cette documentation est une traduction communautaire non officielle de Docker.

Meilleures pratiques


  • Utilisez toujours la dernière version de WSL. Au minimum, vous devez utiliser WSL version 2.1.5, sinon Docker Desktop peut ne pas fonctionner comme attendu. Les tests, le développement et la documentation sont basés sur les versions de noyau les plus récentes. Les versions plus anciennes de WSL peuvent causer :

    • Docker Desktop de se bloquer périodiquement ou lors de la mise à niveau
    • L'échec du déploiement via SCCM
    • Le vmmem.exe de consommer toute la mémoire
    • Les politiques de filtre réseau d'être appliquées globalement, pas à des objets spécifiques
    • Des échecs GPU avec les conteneurs
  • 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 from Microsoft.

    • 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.
    • 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.
    • 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.
  • If you have concerns about the size of the docker-desktop-data distribution, take a look at the WSL tooling built into Windows.

    • 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).
    • 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.
  • 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.