Your Search Bar For Shrewd Tips

How To Activate Wsl Integration In Docker Desktop


How To Activate WSL Integration In Docker Desktop

If you're a developer working with Docker on Windows, enabling Windows Subsystem for Linux (WSL) integration in Docker Desktop can significantly streamline your workflow. WSL allows you to run Linux distributions natively on Windows, and integrating it with Docker Desktop offers a seamless experience for managing containers and developing cross-platform applications. In this guide, we'll walk you through the steps to activate WSL integration in Docker Desktop, ensuring you can leverage the full power of Docker combined with WSL on your Windows machine.

Prerequisites for WSL Integration with Docker Desktop

Before you begin, it's essential to ensure your system meets the necessary requirements for WSL integration with Docker Desktop:

  • Windows 10 or Windows 11: Ensure your Windows version supports WSL 2. Windows 10 version 1903 or higher (with KB5000842 update) and Windows 11 are compatible.
  • Enable the Windows Subsystem for Linux (WSL) feature: This is necessary to run Linux distributions natively on Windows.
  • Install WSL 2: WSL 2 provides a full Linux kernel and improved performance over WSL 1.
  • Install Docker Desktop for Windows: Make sure you have the latest version of Docker Desktop installed, as WSL integration features are enhanced in recent releases.

Step 1: Enable WSL and Virtual Machine Platform Features

The first step involves enabling the required Windows features: WSL and Virtual Machine Platform. Follow these steps:

  1. Open PowerShell as Administrator by right-clicking the Start menu and selecting Windows PowerShell (Admin).
  2. Run the following commands to enable the features:
  3.  dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  4. After executing these commands, restart your computer to apply the changes.

Step 2: Install WSL 2 and a Linux Distribution

Next, you'll need to install WSL 2 and set up a Linux distribution such as Ubuntu:

  • Download and install the WSL 2 Linux kernel update package from the official Microsoft website: https://aka.ms/wsl2kernel.
  • Set WSL 2 as the default version for new Linux distributions:
wsl --set-default-version 2
  • Open the Microsoft Store, search for your preferred Linux distribution (e.g., Ubuntu), and install it.
  • Launch the Linux distribution once installed, complete the initial setup, and ensure it's running properly.
  • Step 3: Install and Configure Docker Desktop

    If you haven't installed Docker Desktop yet, download it from the official Docker website:

    Once installed, launch Docker Desktop and proceed with the configuration:

    Step 4: Enable WSL 2 Integration in Docker Desktop Settings

    To activate WSL integration within Docker Desktop, follow these steps:

    1. Open Docker Desktop from the system tray or Start menu.
    2. Click on the gear icon (Settings) to access Docker Desktop preferences.
    3. Navigate to the Resources tab, then select WSL Integration.
    4. In the WSL Integration section, you'll see a list of installed WSL distributions.
    5. Toggle the switch next to the Linux distributions you want to enable Docker WSL integration for (e.g., Ubuntu).
    6. Ensure that the "Enable the experimental WSL 2 based engine" option is enabled if available.
    7. Click Apply & Restart to save your settings and restart Docker Desktop.

    Step 5: Verify WSL Integration is Active

    After restarting Docker Desktop, it's important to verify that WSL integration is active:

    • Open a terminal (PowerShell or Command Prompt).
    • Run the command:
    docker info
  • Look for the section Remote API and ensure that the WSL distributions are listed under WSL 2.
  • You can also run a test container:
  • docker run hello-world
  • If the container runs successfully, your WSL integration is functioning properly.
  • Additional Tips for Optimal WSL-Docker Integration

    • Keep Docker Desktop and WSL updated: Regular updates improve stability, performance, and compatibility.
    • Assign resources appropriately: Adjust CPU, memory, and disk space in Docker Desktop preferences under Resources to optimize performance based on your system capabilities.
    • Use WSL 2 as your default backend: In Docker Desktop Settings, under General, set the default backend to WSL 2 for a smoother experience.
    • Manage multiple distributions: You can enable Docker integration for multiple WSL distributions if needed.

    Conclusion

    Activating WSL integration in Docker Desktop unlocks a powerful environment for Windows users to develop, test, and run Linux containers seamlessly. By following the steps outlined above—enabling required Windows features, installing WSL 2, setting up your Linux distribution, configuring Docker Desktop settings, and verifying the integration—you can significantly enhance your development workflow. With WSL and Docker working together, you'll enjoy faster performance, easier management of containers, and a more unified development environment. Start integrating WSL with Docker Desktop today and take your Windows-based development to the next level.


    Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.

    Shrewdnia

    Shrewdnia

    Shrewdnia is a destination for curious minds seeking clarity, knowledge, and informed perspectives. Through insightful articles and practical guides our passionate team explores a wide range of topics designed to help readers understand the world around them, make smarter decisions, and stay informed in an ever-changing landscape.


    💡 Every question sparks discovery, and every perspective enriches the conversation. Share your thoughts and insights in the comments 👇

    Back to blog

    Leave a comment

    JOIN THE SHREWDNIA COMMUNITY FORUM

    What do you think?

    Have an opinion, experience, or question about this topic? Join the Shrewdnia Forum and share your thoughts with other readers.

    Join the Forum →