Reputation: 1047
Here is my setup:
Windows 10 PRO - build 19041.153
- insider program - slow ringUbuntu 18.04LTS
subsystem in WSL2 modeDocker for desktop 2.2.0.4
- enabled WSL2 integration with my Ubuntu subsystemI am currently forced to use Windows for development, so I became a Microsoft insider member and installed ubuntu with WSL2 mode. Docker desktop supports integration for WSL2, so I tried it...
For a week it worked flawlessly. Today after a PC restart, I can't get docker running again. Ubuntu can see the injected binaries from Docker desktop, but it can't connect to windows hosted docker daemon anymore.
When I call in the WSL terminal docker info
it returns
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
or with docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
What I've tried already:
DOCKER_HOST=localhost:2375
, DOCKER_HOST=tcp://localhost:2375
, DOCKER_HOST=127.0.0.1:2375
, DOCKER_HOST=tcp://127.0.0.1:2375
=> same resultI really, really need this to work. Thanks for any ideas. Weirdest thing is it worked yesterday and I didn't make any changes in system from then...
Upvotes: 81
Views: 128515
Reputation: 13285
I had installed Docker for Windows, as recommended, to use it with WSL 2 and that does indeed start the docker daemon for you. But I don't need all the fancy features it offers so removed it and was pleased to see about 4GB freed and no extra icon in the system tray.
Now if I need to run docker commands I just begin with:
sudo dockerd &
sudo dockerd > /dev/null 2>&1 & # or this to suppress output
This way I can have it running on the background on the same shell. Note that in this example I have setup sudo
without password. If a password is required, I can do sudo dockerd
and open another terminal tab.
Although this works as a quick temporary solution I've seen it cause network issues. In one machine I prefer using a light VM instead.
Upvotes: 13
Reputation: 1040
Updating the Docker desktop in Windows worked for me! Not sure why no one mentioned
Upvotes: 0
Reputation: 410
Try launching the docker service inside wsl2:
sudo service docker start
Verify the server is running
docker info
Upvotes: 1
Reputation: 13095
The following sequence worked for me:
It wasn't until step 5 that it actually started working.
I did have a container running at the time and "Apply & Restart" happened suspiciously fast, so I suspect it forgot to do the actual restarting part.
Upvotes: 0
Reputation: 11226
I found a 1.5 step fix. Go here, uncheck Enable
, then Apply & restart
button.
Then check Enable
, then Apply & restart
button.
Docker now working fine in WSL2 Ubuntu.
Upvotes: 5
Reputation: 946
I know this may be outdated for the present question, but this should save us precious time, especially when Windows 20H1=2004 is going to Production this month (May 2020).
Operating System Version: Windows 10 Education (Same as Enterprise and a superset of Pro).
Version: 2004
Build (Version OS): 19041.264
Others: Windows Feature Experience Pack 120.2202.130.0.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shell: WSL Terminal
First, I have installed WSL v1 previously, then executed the procedure to upgrade to WSLv2, and this error shows up: "ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?".
Second, to fix that error, I followed instructions stated here: Link, and it worked.
Third, after some tests I think the missing change in the upgrade, was removing the DOCKER_HOST
variable from shell's start script.
SUMMARY: In my case, the procedure for a permanent fix should be the following STEPs:
1. Test if it's your case unsetting DOCKER_HOST
variable (See image below).
2. If the error disappears with previous step, then time to fix changes by removing the setting of the DOCKER_HOST
variable in the shell's start script (In my case was *$HOME/.bashrc*
).
Commented this out:
#export DOCKER_HOST=tcp://localhost:2375
#export DOCKER_BUILDKIT=1
NOTE: Also include DOCKER_BUILDKIT
.
3. Close and open the Terminal.
Upvotes: 74
Reputation: 31
I had the same problem, the solution for me was to set my Ubuntu as the default wsl distribution: wsl --set-default Ubuntu
Upvotes: 3
Reputation: 101
1.open windows docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
2.and then Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
3.click apply and restart
4.then go to ubuntu
try docker ps
docker ps
if it does not work, continue to run the following command
unset DOCKER_HOST
to disable DOCKER_HOST
Today I just tried it successfully
good luck to you
Upvotes: 10
Reputation: 790
The accepted answer is mostly correct. However, I wanted to specify that when using WSL2 + Docker Desktop:
~/.bashrc
in both Windows and WSL.env | grep -i docker
to make sure it's gone.Export daemon on tcp://localhost:2375 without TLS
Use the WSL2 based engine
Enable integration with my default WSL distro
Now, you can do a simple docker info
to check if you're running the same server version in WSL and in Windows (Powershell).
Upvotes: 2
Reputation: 21
After hours, my docker worked using following method.
Go to docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
Restart Docker desktop
Now in WSL,
unset DOCKER_HOST
Now try,
docker ps
Upvotes: 2
Reputation: 41
There is another very basic catch:
Upvotes: 0
Reputation: 345
I've tried soooo many things, and the stuff that worked for me, and no one ever mentioned to try:
(from Windows Powershell)
wsl --set-default <my-distro>
then and there, I could connect to docker without changing the DOCKER_HOST
var.
Upvotes: 15
Reputation: 555
On the Docker Desktop app I had to manually enable my distro integration under
Settings > Resources > WSL Integration
Upvotes: 43
Reputation: 1
For whatever it's worth (this is an old thread). Maybe someone else is still desperately trying to solve this puzzle.
I have just stumbled over the solution in my case. I am running the following
My ultimate error were access rights on /var/run/docker.sock, and I am running wsl under my personal user srw-rw---- 1 root docker 0 May 7 10:29 /var/run/docker.sock
So if I run as root (sudo docker info) or I put myself into group "docker" (sudo usermod -aG docker $USER) I'm all well. Please look here https://docs.docker.com/engine/install/linux-postinstall/
Upvotes: 0
Reputation: 399
I have found my issue was due to mis-reading instructions., fixed on my windows version 1909 and WSL 2 with the following commands on CMD:
wsl.exe -l -v
wsl.exe --set-version ${distro-name} ${wsl version}
example:
C:\Users\xxxxx>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu-18.04 Running 1
docker-desktop-data Running 2
docker-desktop Running 2
C:\Users\xxxxx>wsl.exe --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
That's it
Upvotes: 4
Reputation: 65
ISSUE: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375
wsl -l -v # ALL DISPLAY "2"
unset DOCKER_HOST
/etc/init.d/docker restart
windows docker restart
windows firewall off
docker ps
Upvotes: 2
Reputation: 1
you can consider upgrading your version to 19582.1000 , it's work for me.
See this issue.
Upvotes: -1
Reputation: 921
If it helps anyone else that is having this issue, for me it turned out that my subsystem was suddenly (and "on its own") ticked off in docker's RESOURCES > WSL INTEGRATION settings.
Upvotes: 82