Have you ever faced cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running? on Windows / WSL? This means you've installed only docker CLI, but docker daemon is still not working.
Windows Subsystem for Linux is a Linux environment which could be installed on Windows 10 machines and then could be used to run linux binaries. But WSL 1 was too limited to be compatible with the docker daemon as it requires a set of low level features.
WSL 2 is a brand new environment (read more on microsoft website) which supports easy integration with docker host mode. In other words, you don't need stand-alone virtual machines like virtualbox or VMware and complex setup guides anymore, docker will work natively here 😊
To install WSL 2 on your Windows 10 Home (or Windows 10 Pro) use this WSL 2 update guide. To make docker work then, carefully execute all steps including installing
Get the Docker from official docker website and install it:
Docker Desktop from Start menu.
WSL Integration. If you had WSL 1 before WSL 2 like most of us, it might show you
You don't have any WSL 2 distro...:
How to fix "You don't have any WSL 2 distro"
Now configure your WSL distribution to run WSL version 2 (I had 1 by default).
To check current version, just run in
wsl.exe -l -v
It will show:
C:\Users\Ivan>wsl.exe -l -v NAME STATE VERSION * Ubuntu-18.04 Stopped 1 docker-desktop-data Running 2 docker-desktop Running 2
Ignore docker distributions. The first line holds your real distribution. To set version 2 I executed :
wsl.exe --set-version Ubuntu-18.04 2
Ubuntu-18.04 is the distro name from
wsl -l -v command. It takes a few minutes😐, but don't close the terminal.
When it is finished, click
Apply and Restart 💪:
Run your distro terminal from the start menu:
Now execute 🚀
docker run -d -p 80:80 docker/getting-started
And open https://localhost/ then:
Congratulations, it is working🎉
What should you do if you "cannot connect to the docker daemon"
If you are receiving some sort of:
- cannot connect to the Docker daemon at unix:///var/run/docker.sock. is the docker daemon running?
- couldn't connect to docker daemon at http+docker://localhost - is it running?
- cannot connect to docker daemon
- error: couldn't connect to docker daemon at http+docker://localhost - is it running?
Then it means that the docker daemon not running, so please make sure that your docker daemon is running.
If you would be on Linux, you should do:
service status docker
The difference on Windows WSL 2, that you should still visit Docker Desktop from the start menu to make sure the daemon is working.
If you just updated from WSL 1 to WSL 2 or just installed WSL 2 I strongly recommend to read our WSL 2 starter guide, it has explanation of super-popular problems and tips which you will most probably face if you are new to WSL 2. In short docker ussage tips are consequently flow from the starter guide:
- Please store all sources and volumes inside of the linux filesystem in WSL. (I.e. Paths from
~/...). For example
docker run -v ~/proj:/sources <my-image>is ok when
docker run -v /mnt/c/users/kenny/proj/sources <my-image>might have much worthier performance
- Use WSL Remote extansion if you are using VSCode