-
Notifications
You must be signed in to change notification settings - Fork 11
Troubleshooting
This is a list of (hopefully) helpful snippets. Please open an issue if you need help with something that is not listed here.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
If after changing some configuration such as /etc/docker/daemon.json the docker daemon doesn't start, you can connect to the WSL image manually using
wsl -d clf_dockerinwsl.
From in there, you can execute this command to manually start the docker daemon: dockerd -H unix:///var/run/docker.sock -H tcp://127.0.0.1:2375
This will allow you to see any potential syntax errors or other errors the docker daemon encounters when starting.
ℹ️ If you just want to start docker double-click on the link in the Startup Folder (open with Win+R > type
shell:startup)
docker: Error response from daemon: Get "<address>": dial tcp <IP>: connect: no route to host.
Depending on the IP ranges used by your local networks, there is a chance a collision between the docker network and your local network exists. To avoid that, you can specify a default address pool by modifying your /etc/docker/daemon.json like this:
{
"default-address-pools": [
{
"base":"10.10.0.0/16",
"size":24}
]
}ℹ️ Also check your existing docker networks (
wsl -d clf_dockerinwsl -- sh -c 'docker network ls -q ^| xargs docker network inspect'). There might be old ones that are still using the old network-range, messing with your routing.
To get all ports WSL is providing as "localhost"-ports run the following in a elevated powershell:
Get-Process -Name "wsl*" | %{ Get-NetTCPConnection -OwningProcess $_.id -ErrorAction SilentlyContinue }
Sometimes an exposed port is not reachable from the windows host. Please check the following things (preferably in this order):
- Run
wsl -d clf_dockerinwslto connect to the WSL Docker Host. Make sure that the port is exposed by docker (docker ps -alook for0.0.0.0:8080->8080/tcpwhere 8080 is the port you want to connect to) - Test the connection from inside WSL using
nc -vz 127.0.0.1:<port>orcurl -v localhost:<port>(maybe you have to install curl or nc first withapk add nc curl) - If this works docker and docker-proxy is working fine. Next check if the WSL Process was able to open the port. Run
Get-Process -Name "wsl*" | %{ Get-NetTCPConnection -OwningProcess $_.id -ErrorAction SilentlyContinue }in PowerShell as Administrator. Look for the port you want to connect to. - Also check the open ports in WSL
netstat -tulpnand in windows cmd withnetstat -ano -p tcp.
It is possible that a windows process is using the port "masking" your service: If netstat -ano ... in Win shows an open port and Get-Process ... does not, look at the process-id in netstat and find it in Taskmanager or by running Get-Process <id>. Shutdown the conflicting application. Maybe restart your machine.
If everything is fine in Linux and nothing at all shows up in Windows it might has to do with the portexclusion list. Check it by running netsh int ipv4 show excludedportrange protocol=tcp in an admin-cmd. If the port falls between some given ranges it might help to restart winnet. Run Restart-Service winnat and check the ports again. The exclusion should be gone now. Restart wsl (wsl --shutdown clf_dockerinwsl followed by running the startup link in shell:startup (Win+R > shell:startup). After this restart the docker-container and test again.
Last known option is a colliding port forwarding rule. Run netsh interface portproxy show v4tov4 and check if something is configured here. WSL2 does not need portproxy for localhost connections. You can remove settings using netsh interface portproxy delete (see help command for details).