This write-up will describe how to run or use Docker in WSL without the Docker Desktop application.
How to Run Docker in WSL Without Docker Desktop?
To utilize the WSL (Windows Subsystem for Linux) to run the Docker CLI without the Desktop application, first install or enable the WSL on Windows. Then, download any Linux distribution, such as Ubuntu 22.04, and use it to install Docker. For the demonstration, follow the provided instructions.
Step 1: Install WSL Latest Version
First, open the Microsoft Store from the Windows Start menu:
After that, search for WSL and install it. However, users can also utilize the built-in WSL by enabling it from “Windows Features”. But the newest version of WSL is preferable due to its advanced features, such as the “systemd” utility:
Alternatively, you can update the built-in WSL to the Microsoft latest version of WSL using the “wsl –update” command:
For the verification, check out the WSL version:
Step 2: Install Linux Distribution
After installing or enabling WSL on Windows, install any Linux distribution. For instance, we have installed “Ubuntu 22.04.2” on Windows:
Note: Latest version of WSL supports Ubuntu version 20 or more:
Step 3: Set Username and Password
After that, launch the Linux distribution from the Windows “Startup” menu and set the Linux username and password as shown below:
Step 4: Update APT Repository
After that, update the Ubuntu APT repository using the “sudo apt update” command:
Here, you can see we have successfully updated the apt repository:
Step 5: Install Docker
Next, install the Docker by utilizing the below command. Here, the “-y” option is used to grant the permission to install required packages automatically:
Step 6: Make a New User
After installation of Docker, make a new user group with the name “docker” by utilizing the below-mentioned command:
Step 7: Check Docker Version
For the verification, check out the version of Docker on WSL Linux distribution:
Here, you can see we have installed the Docker version “20.10.12”:
Step 8: Shut Down WSL Using PowerShell
Now, shutdown the WSL from the Windows Powershell:
Step 9: Run Docker on Linux Distribution
Again, start the Ubuntu from the Start menu and run the “docker run hello-world” and check if the Docker is working on WSL or not:
From the above output, it can be observed that we have successfully run Docker on WSL.
To run or utilize Docker in WSL, first install or enable the WSL on Windows. Then, install any Linux distribution, such as Ubuntu 22.04. Then, install Docker using the “sudo apt install docker.io” command. After that, make the new user group named “docker” and start running Docker on WSL. This write-up has illustrated how to use or run Docker in WSL without using Docker Desktop.