docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 287 forks source link

ubuntu running under WSL2 not seeing Docker daemon at unix:///var/run/docker.sock #5096

Closed mwoodpatrick closed 1 year ago

mwoodpatrick commented 4 years ago

When running docker desktop version 2.1.5.0 (40323) on:

OS Name: Microsoft Windows 10 Pro OS Version: 10.0.19013 N/A Build 19013

Eben though WSL 2 based engine is enabled in Settings/General

docker container run hello-world on Ubuntu reports

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'.

zeehjr commented 4 years ago

Which output do you see when running the following statement on powershell/cmd? docker context ls

Which output is returned when you run the follow statement on WSL terminal? docker ps

liyo commented 4 years ago

Same issue here.

@zeehjr

C:\WINDOWS\system32>docker context ls
NAME                DESCRIPTION                               DOCKER ENDPOINT                  KUBERNETES ENDPOINT   ORCHESTRATOR
default             Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine                         swarm
wsl *               Docker daemon hosted in WSL 2             npipe:////./pipe/docker_wsl

and from Ubuntu WSL2 (only distro installed)

docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Strangely, the WSL Integration option is not available from Settings > Resources. WSL 2 based engine is enabled in Settings > General. Docker CLI is installed in Ubuntu.

liyo commented 4 years ago

Fixed it by switching to Linux containers...

mwoodpatrick commented 4 years ago

I'm running with Linux containers and am seeing problem

in power shell

PS C:\WINDOWS\system32> docker context ls NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR default * Current DOCKER_HOST based configuration npipe:////./pipe/docker_engine swarm wsl Docker daemon hosted in WSL 2 npipe:////./pipe/docker_wsl

In WSL 2 ubuntu shell

docker ps Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

On Thu, Nov 7, 2019 at 3:39 PM Pablo Wolochwianski notifications@github.com wrote:

Fixed it by switching to Linux containers...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/5096?email_source=notifications&email_token=AAQ6SQWJIKQKG2KOW7HB67LQSSRM3A5CNFSM4JKMAN3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDOGZFQ#issuecomment-551316630, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ6SQQONCXEHFKQNON3W6TQSSRM3ANCNFSM4JKMAN3A .

-- Mark Wood-Patrick

simonferquel commented 4 years ago

@mwoodpatrick you need to go to the settings, and enable integration with your distro in "Resources -> WSL Integration".

mwoodpatrick commented 4 years ago

Many thanks that worked

On Fri, Nov 8, 2019 at 12:02 AM Simon Ferquel notifications@github.com wrote:

@mwoodpatrick https://github.com/mwoodpatrick you need to go to the settings, and enable integration with your distro in "Resources -> WSL Integration".

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/5096?email_source=notifications&email_token=AAQ6SQULY6OFOLPGZ4CZT5DQSUMJ3A5CNFSM4JKMAN3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDPBSGY#issuecomment-551426331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ6SQSKF43N7HNUV4OW4LTQSUMJ3ANCNFSM4JKMAN3A .

-- Mark Wood-Patrick

mikedickey commented 4 years ago

Ran into same problem, and resolved via "Resources -> WSL Integration"

This isn't clear anywhere, so I'd suggest adding a popup or something when you "Enable the Experimental WSL 2 Engine." Perhaps it should prompt you for list of distros you want to enable after you turn it on?

simonferquel commented 4 years ago

Thanks for those feedback. I understand that this new behavior causes issues. We are giving some thoughts at always enabling integration with the default WSL distro. Would it make things better ?

mwoodpatrick commented 4 years ago

That would work for me, or perhaps a dialog box at startup showing which distros are enabled and ability to modify that would be better, perhaps with an option not to show this dialog at startup in future

On Tue, Nov 12, 2019 at 12:57 AM Simon Ferquel notifications@github.com wrote:

Thanks for those feedback. I understand that this new behavior causes issues. We are giving some thoughts at always enabling integration with the default WSL distro. Would it make things better ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/5096?email_source=notifications&email_token=AAQ6SQU7FG737QKO3AZBLKDQTJVYLA5CNFSM4JKMAN3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDZQLIY#issuecomment-552797603, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ6SQSVNJSL77RB5S4XN2TQTJVYLANCNFSM4JKMAN3A .

-- Mark Wood-Patrick

stewartadam commented 4 years ago

A simple note under the Enable the WSL 2 based engine heading (as there is already in light grey) noting the requirement to also configure distros, along with a hyperlink/button to jump there would be more than sufficient.

HawkiesZA commented 4 years ago

Having something pop up in General settings telling you which distros are enabled (and maybe warning you that none are currently active) would be helpful.

ilerik commented 4 years ago

@mwoodpatrick you need to go to the settings, and enable integration with your distro in "Resources -> WSL Integration".

Thanks a lot! Never thought of such a possibility!

luck02 commented 4 years ago

I can't seem to get the WSL context:

PS C:\WINDOWS\system32> docker context ls
NAME                DESCRIPTION                               DOCKER ENDPOINT                  KUBERNETES ENDPOINT   ORCHESTRATOR
default *           Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine                         swarm
PS C:\WINDOWS\system32>

I've enabled wsl 2 for my ubuntu machine. But in ubuntu terminal I get:

 13:00:41  gary@GaryLaptop  ~ 
$ docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I'm on docker desktop 2.1.7.0 (41536)

Output from PS wsl -l -v

PS C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-18.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2
PS C:\WINDOWS\system32>
flipch commented 4 years ago

I can't seem to get WSL 2 to connect with Docker.

From powershell image

From WSL 2 Debian image

Docker version image

Docker Resources > WSL Integration image

Am I missing something?

luck02 commented 4 years ago

One update, when I check the docker logs I do see this:

[13:07:57.685][WslIntegrationAgent-Ubuntu-18.04][Info   ] time="2019-12-13T13:07:57-08:00" level=fatal msg="unable to populate CLI tools: symlink /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose /usr/bin/docker-compose: file exists"
[13:07:57.747][WslIntegrationAgent-Ubuntu-18.04][Info   ] 2019/12/13 13:07:57 Proxy error: exit status 1

Which is presumably cruft leftover from my WSL 1 based ubuntu instance.

ldormoy commented 4 years ago

I ran into the same issue.

I had to delete all WSL broken symbolic links previously created by Docker Desktop. Reinstalling Docker Desktop was not enough.

Here are the commands I ran to achieve that:

sudo find /usr -name "*docker*" -type l -exec rm {} +
sudo find /usr -name "*Docker*" -type l -exec rm {} +
sudo find /usr -name "*kube*" -type l -exec rm {} +
sudo rm /usr/share/doc/docker-ce-cli/changelog.Debian.gz

Then I restarted docker desktop and it worked again:

powershell$ docker context ls
NAME                DESCRIPTION                               DOCKER ENDPOINT                  KUBERNETES ENDPOINT   ORCHESTRATOR
default *           Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine                         swarm

wsl$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS          NAMES

Docker Desktop: 2.1.7.0-edge Windows: 10.0.19041.1 WSL 2: Ubuntu 18.04

snapfreeze commented 4 years ago

I can't seem to get WSL 2 to connect with Docker.

From powershell image

From WSL 2 Debian image

Docker version image

Docker Resources > WSL Integration image

Am I missing something?

Having the same issue. There's no wsl context after enabling the WSL 2 experimental features, and I can't access docker from inside the wsl.

daneel3001 commented 4 years ago

Hello

I seem to have the same issue. Docker Desktop: 2.1.7.0-edge Windows: 10.0.19041.1 WSL 2: Ubuntu 18.04

Reinstalled DD and reenabled WSL2 integration still didn't create the WSL context. Can anyone provide trusted installation steps for getting this working ?

@ldormoy : As you didn't have WSL context enabled and now have it, can you explain all steps you did take in addition to the commands you shared?

FYI, in Ubuntu having uninstalled Docker Desktop am having this:

 daniel  ~  docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea838
 Built:             Wed Nov 13 07:29:52 2019
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Thanks

ldormoy commented 4 years ago

As you didn't have WSL context enabled and now have it, can you explain all steps you did take in addition to the commands you shared?

Well that's the thing, I don't have it but it still works. I don't know whether this WSL context is a legacy feature from WSL 1, but in my case all I did was to check the docker logfile (it is available if you start a troubleshooting session) and delete the broken symbolic links until the logs are clean.

luck02 commented 4 years ago

https://github.com/docker/for-win/issues/5096#issuecomment-565633357

After I deleted the docker cruft from my original install everything worked. In my case I think I also found I had serious issues with my zsh config so I just blew away my ubuntu and started fresh. Worked fine after that, still no second WSL context, not sure what that all means though.

ankitjena commented 4 years ago

@mwoodpatrick you need to go to the settings, and enable integration with your distro in "Resources -> WSL Integration".

Which settings? I am using docker cli in WSL

jaimergp commented 4 years ago

@ankitjena Click on Docker's tray icon. Then navigate to Settings> Resources> WSL Integration.

delusive commented 4 years ago

Just a heads up for anyone having this issue and everything here has been checked out.

I realized that docker-desktop-proxy process wasn't running inside the distribution (ps aux | grep docker-desktop-proxy).

I tried to start it manually with the following command (copied from a working system):

sudo /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu --docker-desktop-root /mnt/wsl/docker-desktop

When I ran this I got the following error:

FATA[0000] open /mnt/wsl/docker-desktop-bind-mounts/Ubuntu/780bef17cf3a89fb203c54a75bff8f6fc2d93d444b904ef0cf4c5e4fcacd73ac: is a directory

So I went into Settings -> Resources -> WSL Integration and turned it off for the distribution not working.

Then I removed that docker-desktop-bind-mounts directory.

Flipped back on the WSL Integration for the distribution and bang it works.

Hope this helps anyone else.

Cheers.

simonferquel commented 4 years ago

Thanks for the workaround. I should be able to use that for fixing the underlying issue.

altwohill commented 4 years ago

I'm finding that docker turns off the WSL integration every now and again. It also looses my sign-in information. All the other settings seem to stay in place

nielswart commented 4 years ago

I'm running Docker Desktop 2.2.0 and I'm unable to run docker on my wsl distro without sudo.

image

Also note that: docker context ls only shows a single context as explained here https://github.com/docker/for-win/issues/4361#issuecomment-557427409 - hope that helps

altwohill commented 4 years ago

I'm running Docker Desktop 2.2.0 and I'm unable to run docker on my wsl distro without sudo.

You need to follow the instructions here https://docs.docker.com/install/linux/linux-postinstall/

simonferquel commented 4 years ago

@nielswart there is not "docker_wsl" context anymore. Also, you seem to have your DOCKER_HOST environment variable set to tcp://loclhost:23750. You need to unset it to work with docker-desktop.

nielswart commented 4 years ago

@simonferquel

@nielswart there is not "docker_wsl" context anymore. Also, you seem to have your DOCKER_HOST environment variable set to tcp://loclhost:23750. You need to unset it to work with docker-desktop.

Yes, thanks. I just linked that post for others asking about no separate context. My issue was only about running without sudo.

Thanks for the info about the env variable, it solved my sudo issue!

mwoodpatrick commented 4 years ago

The information about docker-desktop-proxy above was very helpful and allowed me to get docker running on my Ubuntu install. Anyone have any good references to the overall docker flow in wsl2 and the docker-desktop-proxy process in particular?

boay24 commented 4 years ago

image

same here ,Today surprised me. os build 19569

pengonorbert commented 4 years ago

I did every step which was shown by the guides, but the docker daemon was not found inside the distro. I managed to find that, i used docker for windows with the wsl 1 previously, and the DOCKER_HOST variable was written in ~/.bashrc file. Removed that line, restarted the terminal, and the docker works like a charm after that.

stuardcg commented 4 years ago

I had the same issue a day before. When I change the Settings->Resources->WSL Integration->Ubuntu to on and close the settings when I go back that setting was off again. Then, cannot connect to the Docker daemon.

After a while dealing with this issue I tried many things to make it work until I broke Ubuntu (Command 'docker' not found). I had no option to reset my Ubuntu and reinstall everything again. After a re-enable the WSL options on the Docker Desktop it starts working

90dy commented 4 years ago

I had the same issue, what I did to make it work is:

image

offero commented 4 years ago

Just a heads up for anyone having this issue and everything here has been checked out.

I realized that docker-desktop-proxy process wasn't running inside the distribution (ps aux | grep docker-desktop-proxy).

I tried to start it manually with the following command (copied from a working system):

sudo /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu --docker-desktop-root /mnt/wsl/docker-desktop

When I ran this I got the following error:

FATA[0000] open /mnt/wsl/docker-desktop-bind-mounts/Ubuntu/780bef17cf3a89fb203c54a75bff8f6fc2d93d444b904ef0cf4c5e4fcacd73ac: is a directory

So I went into Settings -> Resources -> WSL Integration and turned it off for the distribution not working.

Then I removed that docker-desktop-bind-mounts directory.

Flipped back on the WSL Integration for the distribution and bang it works.

Hope this helps anyone else.

Cheers.

Same thing here, except it looks like it's already running:

i λ ps -aux | grep docker  something root 21016 0.0 0.0 498948 20452 pts/8 Ssl+ 14:48 0:00 /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu --docker-desktop-root /mnt/wsl/docker-desktop

When I run it again, it works. IDK why the one that is running is not working correctly.

I want to kill and restart it. What is supposed to start it? How does it get run automatically on WSL 2 start?

crasx commented 4 years ago

Setting the docker host env to the unix path worked for me export DOCKER_HOST=unix:///var/run/docker.sock

djensen47 commented 4 years ago

Here's what worked for me:

use sudo: sudo docker ps

from @crasx export DOCKER_HOST=unix:///var/run/docker.sock

remove from .bashrc or .zshrc export DOCKER_HOST=<whatever>

This last one was my issue. I had an old DOCKER_HOST set from a previous non-WSL2 setup.

~I'm not on Windows Insider but it appears that the docker group is fixes in a newer build: https://github.com/docker/for-win/issues/5668#issuecomment-585625407~

^^ Not sure if that was relevant.

ghost commented 4 years ago

Setting the docker host env to the unix path worked for me export DOCKER_HOST=unix:///var/run/docker.sock

this works. thanks a lot dude

myusrn commented 4 years ago

I'd suggest folks take a look at https://docs.docker.com/docker-for-windows/wsl-tech-preview/ which outlines the new wsl2 based docker for windows service setup and new location in settings where it gets enabled.

nelak commented 4 years ago

Trying to provide more information on this: Docker version 19.03.8, build afacb8b7f0 is working on with WSL2 on my ubuntu Release: 19.10 but not working on Release: 18.04 Hoping to migrate to 20.04 soon

myusrn commented 4 years ago

Hi @nelak can i ask for clarification on how are you going about enabling a wsl2 ubuntu distribution 'Release: 19.10' install?

I ask because on my win10 2004 19041.207 setup when i install the store app wsl ubuntu non-release specific offering, presumable the latest version, and then from wsl2 terminal execute uname -a it shows Linux myDevB 4.19.84-microsoft-standard #1 SMP Wed Nov 13 11:44:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux.

I see in the store app that it also offers a release specific wsl ubuntu 18.04 LTS which when i install it as well and from its wsl2 terminal execute uname -a it unexpectedly outputs the same Linux myDevB 4.19.84-microsoft-standard #1 SMP Wed Nov 13 11:44:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux details.

nelak commented 4 years ago

@myusrn I installed it directly from sources not through the app store and using the install instructions everything went smoothly. One thing that I think I did differently in this install was installing docker-ce-cli directly through apt-get instead of brew On the other hand I just updated my 18.04 install and it is still failing, but this was originally a WSL1 install. I'll be giving installing a fresh 20.04 install to see how it works.

myusrn commented 4 years ago

@nelak thanks for clarifications. How does one install an ubuntu distribution directly from sources, versus the msft app store, into the windows 10 wsl2 environment? I've installed ubuntu distributions directly from sources but in those cases im installing it into a hyper-v vm setup not wsl2 environment.

nelak commented 4 years ago

@myusrn Using the corresponding rootfs, this also allows you to specify another location for vhdx file wsl --import <DistributionName> <InstallLocation> <FileName>

You can find the rootfs links for the different versions here: https://wiki.ubuntu.com/WSL#Installing_Ubuntu_on_WSL_by_sideloading_the_.appx

tegaaa commented 4 years ago

@nielswart there is not "docker_wsl" context anymore. Also, you seem to have your DOCKER_HOST environment variable set to tcp://loclhost:23750. You need to unset it to work with docker-desktop.

This fixed it for me. You need to unset DOCKER_HOST the whole integration bit does it for use. After I remove the env_var I was able to run docker without sudo in my distro. Worked like a charm. Thanks @simonferquel

nassaz commented 4 years ago

WSL uses linux socket connection instead TCP connection :

export DOCKER_HOST=unix:///var/run/docker.sock should work properly.

simonmatt commented 4 years ago

@pengonorbert I did every step which was shown by the guides, but the docker daemon was not found inside the distro. I managed to find that, i used docker for windows with the wsl 1 previously, and the DOCKER_HOST variable was written in ~/.bashrc file. Removed that line, restarted the terminal, and the docker works like a charm after that.


This issue cost me a whole day to solve it, and I follow @pengonorbert 's guidance to remove the export DOCKER_HOST=tcp://localhost:2735 variable from my ~/.zshrc, then restart terminal and then run docker version in my terminal, after that it works, thanks very much for @pengonorbert .


OS:Windows 10 build 19041 WSL2: Ubuntu 1804 Docker Desktop: 2.3.0.2(45183)

$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:25:46 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
Xlaudius commented 4 years ago

What worked for me to use docker without sudo was the following: As in the issue @simonmatt suggested, one of the latest comments was about checking on the current service, so i ran:

Im running Ubuntu 20.04 LTS and my Docker desktop configuration nested in General > Expose daemon on tcp://localhost:2375 without TLS is unchecked

After this i was able to run docker commands without sudo, i hope that helps

myusrn commented 4 years ago

@Xlaudius which one of the above steps allowed you to execute wsl2 ubunto distro docker commands w/o requiring use of sudo, was it the fact that you ran sudo service docker start from that environment? Is that command reaching across and starting the windows docker desktop service versus one launching docker desktop from windows sidie of things?

Xlaudius commented 4 years ago

@myusrn , sadly i cannot answer your question, but i will give as much information as i can. Since i tried different things exposed here and in the issue @simonmatt shared , since Docker Desktop seems to pass context to the distro you are using i guess that first of all you have to enable a couple of features before anything, in my case: