Run docker in WSL for better performance and access app from Windows.

Introduction
Running docker on Windows can be really slow. No matter how much you tune the configuration of docker containers, the performance lags far behind when compared to Linux or Mac. One solution to this problem can be to run docker in WSL for better performance.
Windows Subsystem for Linux has revolutionized development by allowing users to run Linux environments directly on Windows without a virtual machine. One of the most common use cases is setting up Docker inside WSL to run web applications. But how do you access your Dockerized web app from Windows?
In this guide, we’ll show how you can run docker in WSL for better performance, running a web app, and accessing it from Windows.
Run docker in WSL for better performance
✅ Prerequisites
Before we begin, ensure you have:
- Windows 11 or Windows 10
- WSL 2 enabled (Run
wsl -l -v
to check your version) - A Linux distribution installed on WSL (Ubuntu recommended)
- Docker installed inside WSL
- Postman installed on Windows (optional)
📌 Step 1: Install Docker Inside WSL
1. Open WSL Terminal (Ubuntu or other distro)
Ensure your system is up-to-date:
1 | sudo apt update && sudo apt upgrade -y |
2. Install Docker
Run the following commands to install Docker inside WSL:
1 | sudo apt install -y docker.io |
3. Start and Enable Docker Service
1 | sudo service docker start |
4. Allow Docker to Run Without “s
udo”
1 2 | sudo usermod -aG docker $USER newgrp docker |
Test Docker installation:
1 | docker run hello-world |
Alternatively, you can also follow the docker’s instruction for your distro here
If you see a confirmation message, Docker is working inside WSL!
📌 Step 2: Run a Web App in Docker Inside WSL
Now, let’s deploy a simple Nginx web server inside Docker.
1. Pull and Run an Nginx Container
1 | docker run -d -p 8080:80 --name nginx-server nginx |
This runs an Nginx server and maps it to port 8080.
2. Check Running Containers
1 | docker container ls |
Your Nginx server should be listed.
3. Verify If the App is Running
Inside WSL, run:
1 | curl http: //localhost :8080 |
If the response contains HTML from Nginx, your web app is live!
📌 Step 3: Access the Dockerized App from Windows
Now, let’s connect Postman (installed on Windows) to the app running inside WSL.
1. Find Your WSL IP Address
Run in WSL:
1 | ip addr show eth0 | grep "inet " | awk & #039;{print $2}' | cut -d/ -f1 |
Copy the output. This is your WSL IP address.
2. Test Connection in Windows
- Open any web browser on Windows.
- Enter this URL in the request bar: – http://<WSL-IP>:8080 (replace <WSL-IP> with the IP address of your WSL)
- You should receive the Nginx response!
By following these steps, you can easily set up Docker inside WSL and access your web apps from Windows. This setup allows you to develop, test, and debug efficiently while leveraging the best of both Linux and Windows environments.