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:
| |
Add Docker’s official GPG key:
| |
Set up the Docker apt repository:
| |
Install Docker Engine:
| |
Verify Installation
Run hello-world to confirm Docker is working:
| |
To avoid typing sudo every time, add yourself to the docker group:
| |
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:
| |
Alternatively, enable systemd support in /etc/wsl.conf (requires Windows 11 22H2 or later):
| |
After making the change, restart WSL2 and Docker will start automatically.
