Originally published at recca0120.github.io
After setting up WSL2, if you want to run Docker but don’t want Docker Desktop (resource-heavy and requires a license), installing Docker CE directly in WSL2 is the cleaner approach.
Installation Steps
Update the package list and install the dependencies needed for apt to use HTTPS:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
Add Docker’s official GPG key:
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Set up the Docker apt repository:
echo
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg]
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
docker-buildx-plugin docker-compose-plugin
Verify Installation
Run hello-world to confirm Docker is working:
sudo docker run hello-world
To avoid typing sudo every time, add yourself to the docker group:
sudo usermod -aG docker $USER
Open a new terminal for the change to take effect.
WSL2 Notes
WSL2 doesn’t start systemd by default, so the Docker daemon may not start automatically. You’ll need to start it manually each time you open WSL2:
sudo service docker start
Alternatively, enable systemd support in /etc/wsl.conf (requires Windows 11 22H2 or later):
[boot]
systemd=true
After making the change, restart WSL2 and Docker will start automatically.
