docker / for-win

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

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

Closed mwoodpatrick closed 2 years ago

mwoodpatrick commented 5 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'.

myusrn commented 4 years ago

Thanks for additional clarifications. I have all that, except under docker desktop | settings | resources | wsl integration i don't have "enable integration with additional distros" because "Ubuntu-20.04" is configured as my default wsl2 distro.

That said on my wsl2 ubuntu 20.04 terminal if i enter sudo service docker status [ or start ] i get docker: unrecognized service. On that distro i have sudo apt install docker.io and i'm wondering what other apt docker package one installs to enable controlling the windows docker desktop service [ "%programfiles%\Docker\Docker\Docker Desktop.exe" ] from the wsl2 ubuntu command line.

Xlaudius commented 4 years ago

@myusrn try to take a look at the Enable integration with additional distros, if yours is listed enable it and restart docker, then try again on the services steps. Many people encountering error cases. Myself included.

DadongZ commented 4 years ago

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.

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.

DadongZ 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?

I solved same issue by:

In Ubuntu terminal: $sudo service docker status it shows docker is not running then $sudo service docker start Docker is running $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 4392e5dad77d 2 days ago 132MB

jiywww 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: #5668 (comment)~

^^ Not sure if that was relevant.

it worked for me. Thank you very much😁

PavelSosin-320 commented 4 years ago

It works on-off for me. It looks like every Windows re-start WSL integration configuration is wiped off. But I see that entire /var/run -> /run in all WSL2 distros is overridden every Windows re-start. Although I have docker-context with default context, it is configured to use sock which is volatile. I have no DOCKER_HOST but it is irrelevant I think because client connectivity shall be defined by the current context and it says "Current DOCKER_HOST based configuration" from one hand and "unix:///var/run/docker.sock" from other. DOCKER_HOST can be inherited from Windows. Doesn't it make a docker client crazy? Me too.

yanoom commented 4 years ago

After trying many solutions, I played with the following settings and fixed it:

PavelSosin-320 commented 4 years ago

I just found looking inside docker desktop distro that although neither service listens to host port 2375 that there is docker proxy process is listening to another port: ps -aef| grep proxy 1787 root 0:00 /usr/local/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3306 -container-ip 172.24.0.2 -container-port 3306. Indeed this port is shown as netstat -an tcp 0 0 :::3306 :::* LISTEN by the netstat at the Windows (docker's node) level I expect that there is some proxy that listens to tcp port, terminates SSH, and communicates with dockerd via Unix socket. Unfortunately, this is not documented and there is no such docker context entry. Could somebody confirm and provide a used proxy configuration?

thelazyanalyst 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

This write up fixed the issue! Thank you. Running Win 10, Docker Desktop and WSL2: Ubuntu

myusrn commented 4 years ago

What "sudo apt install docker???" command is it assumed one will run on wsl2 to enable just the client that leverages the existing docker for windows exposure into the wsl2 instance?

I ask because reading the docks i am unable to make sense of which one is client only and am concerned that "sudo apt install docker" or "sudo apt install docker-io" commands try and install the ubuntu docker daemon/service which ends up tromping on the docker for windows symbolic link's abilities to be the service that the client install sees.

seemethere commented 4 years ago

What "sudo apt install docker???" command is it assumed one will run on wsl2 to enable just the client that leverages the existing docker for windows exposure into the wsl2 instance?

I ask because reading the docks i am unable to make sense of which one is client only and am concerned that "sudo apt install docker" or "sudo apt install docker-io" commands try and install the ubuntu docker daemon/service which ends up tromping on the docker for windows symbolic link's abilities to be the service that the client install sees.

In any case I wouldn't install using the OS packages anyways, the docker supported packages are located at https://download.docker.com and the specific client package you are looking for is named docker-ce-cli

myusrn commented 4 years ago

From what i recall installing docker desktop for windows and enabling wsl2 integration sets up mount paths to docker linux distro clients installed on windows host OS file system so in wsl2 no docker apt package should be needed. That said i always forget and run "sudo apt install docker.io or docker-ce-cli" at which point i'm wrapped around the axle wrt which apt packages to uninstall to get back to the docker desktop for windows provided client apps.

nelak commented 4 years ago

I've finally been able to repro this error consistently. As @myusrn says no docker install is needed, the user needs to be a member of the docker group. On the other hand, if you have changed your shell from /bin/bash to anything else docker.sock doesn't get created resulting in the reported issue. If you switch back the shell to /bin/bash, disable the integration and enable it again docker.sock mounts properly and the docker and kubectl commands will work as expected.

nelak commented 4 years ago

Here's a build that solves the issue when using a different shell See https://github.com/docker/for-win/issues/7653

mpoletto commented 4 years ago

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

My integration is enable and the problem continues.

mpoletto 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.

Worked for me. Now I'm back dealing with the first problem:

Creating network "app_appnet" with driver "bridge" ERROR: Pool overlaps with other one on this address space

Seems windows Linux integration is a disappointment yet. I have been lost a lot of time with things like it. I lost my MySQL container database after begining a day. You go sleep with everything working well and begin another day without a database. Miss my Mac - seven years destroying everything and having no problems. And my programming activity is being worst everyday.

ppkozlowski commented 4 years ago

@mpoletto Thanks for sharing your workaround. Unfortunately for me doesn't work. I deleted /mnt/wsl/docker-desktop-bind-mounts and enable WSL2 integration with default distro and still doesn't work.

Error response from daemon: dial unix /mnt/wsl/docker-desktop/shared-sockets/guest-services/docker.sock: connect: no such file or directory

ps aux | grep docker-desktop-proxy 10:36:18 root 181 0.6 0.0 1386332 24336 pts/1 Ssl+ 10:35 0:00 /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name ubuntu --docker-desktop-root /mnt/wsl/docker-desktop

I tried to reinstall Docker Desktop to the latest but it's not better. Version: 2.3.4.0 (46980) Channel: edge Sha1: 8f3a0bed681d86804266eec8ccb92f39b97a513f

pneborg commented 4 years ago

This fix worked for me: https://stackoverflow.com/questions/60708229/wsl2-cannot-connect-to-the-docker-daemon Tested this by running unset DOCKER_HOST Then run docker ps to see if connecting to docker from WSL2 ubuntu is working. If it is then editing the .bashrc to comment out the DOCKER_HOST fixed this for me.

strarsis commented 4 years ago

Related: https://github.com/docker/for-win/issues/8183

fornous commented 4 years ago

I had a running installation with WSL2 and Docker Desktop and suddenly my WSL2 distro (Ubuntu) stopped working at all. So I did

wsl --shutdown;wsl

and Wsl2 Ubuntu started to work properly, but I was unable to run docker command from it. In Powershell it worked. The error I got was Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

There was a stopped container with bind mount volume from Wsl2 distro. So I did this and it helped:

And it works well since. It seems to be a problem with laptop always on features...

ghost commented 4 years ago

I had the same problem with WSL 2 on debian 10 (without docker desktop). Checking the docker daemon log, the problem seemed from iptables:

time="2020-08-30T18:23:54.858343900+02:00" level=warning msg="Running iptables --wait -t nat -L -n failed with message: iptables v1.8.2 (nf_tables): CHAIN_ADD failed (No such file or directory): chain PREROUTING, error: exit status 4"

So, I changed iptables to legacy mode:

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

Now, It work fine:

$ sudo service docker restart
$ sudo service docker status
[ ok ] Docker is running.

Hope it helps people with the same problem.

PavelSosin-320 commented 4 years ago

Unfortunately, Docker desktop doesn't use Docker context properly. According to the latest Docker spec the Docker end-point is defined in the local user client ocker.config under ~. If you look at Docker context ls output in any distro you will see the same default context pointing to the "local" FIFO socket created in the local FifoFS. For the KubeCTl I solved it using explicit --config parameters or creating simlink in my Linux profile for kubeConfig in my Windows profile. But the difference between Docker and Kubernetes is that Kubernetes API server end-point is always TCP socket with IP address - it doesn't belong to specific local FifoFS.

dark-swordsman commented 4 years ago

Sorry for the rant, but it's funny that ever since upgrading to WSL 2, I've been finding more and more things wrong with WSL that isn't native to linux.

It's sad. I even tried at least setting up some project that is supposed to emulate system.d so I can get most of the things I need running, but that in itself is broken.

WSL was alright when I was developing web apps or node APIs, but beyond that, it's garbage.

There is no reason I should have to download a Windows desktop application just to get docker running in Linux. This is ridiculous.

myusrn commented 4 years ago

@dark-swordsman i believe the guidance to install docker desktop for windows is to facilitate users who want a single shared docker daemon presence in their cmd.exe, windows powershell, [ x-platform ] powershell core and wsl2 distribution terminal. For users that just want docker daemon support in the wsl2 distribution terminal environment they can you can skip the docker desktop for windows install suggestion and go straight to installing docker daemon using process they are used to using in their wsl2 hosted distro environment.

ahmednrana 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: #5668 (comment)~ ^^ Not sure if that was relevant.

it worked for me. Thank you very much😁

This worked for me. thanks

dhulke commented 4 years ago

For me this error happened because for some reason, some containers kept running, even though they wouldn't appear when running docker container ls. I had to go to the UI and delete it from there and restart docker desktop

jamescanady commented 4 years ago

I ran into the same issue After enabled WSL 2 support, I was unable to connect to my docker instances. After reading through the comments, I finally found a suggestion to remove the previous DOCKER_HOST entry from my .bashrc file. Doing so resolved the issue.

As noted, remove any previous entries in .bashrc or .zshrc files.

PavelSosin-320 commented 4 years ago

In my latest 2.4.1 CE release, Docker is back to service after 6 months vacation. Docker CLI for Windows can be installed from Chocolatery. Once, a long time ago I had a good one Docker CLI from Docker CLI from Choco. It was OK but an old Spec Version. Now it shows Docker 19.03.12, the latest spec. Anyway, don't use DOCKER_HOST because in this spec it is going to be deprecated and Docker context is much more convenient in the maintenance. Dockercontext creation takes 1 minute for the given host. It creates a plain file that can be copied to UserProfile.Focker folder or /home/User/.docker, exported-imported as a tar, etc. And doesn't pollute the environment.

PavelSosin-320 commented 4 years ago

Sorry, I forget to write that I added host = tcp: // 127.0.0.1 to the daemon config according to WSL 2 straight common sense and to avoid interpretation of localhost as {::1] but ignore : WARNING: API is accessible on http://0.0.0.0:2375 without encryption. Access to the remote API is equivalent to root access on the host. Refer because of wsl -d docker-desktop -u root does exactly the same.

dsarmis commented 4 years ago

I had a similar problem, and it seems that something was stuck in the "enable integrations with my default WSL distro" I had a broken wsl 1 ubuntu (did not manage to update it to wsl 2) and after removing it and checking again the "enable integrations with my default WSL distro", and selecting the distro from below and restarting docker for windows, it worked.

npujcong commented 3 years ago

I solve my probolem with https://docs.docker.com/docker-for-windows/wsl/

PavelSosin-320 commented 3 years ago

I have perfectly working WSL2 Ubuntu 20.04 with all additions provided by Ubuntu developers like systemd enablement. Maybe, the problem is that Ubuntu 20.04 works too well? They are ahead in the CNCF rase but RedHat is closing the gap.

AbelHu commented 3 years ago

Thanks @pneborg. It works for me after below changes.

milesrae4 commented 3 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 #4361 (comment) - hope that helps

I experienced the same problem and even after going through the following instructions: https://docs.docker.com/engine/install/linux-postinstall/ , still did not allow me to execute docker commands without sudo. However if i run "unset DOCKER_HOST" each time the bash terminal opens, it seems to allow me to to run docker without sudo. I checked my .bashrc file and i dont have an existing DOCKER_HOST variable being set in there as other people are saying to comment it out, but i cant seem to find where its being set. The work around i found was to add the following lines to my ~/.bashrc file

echo "Removing DOCKER_HOST "
unset DOCKET_HOST

There probably is a better solution than this, but it worked for me in the meantime. This will then unset the DOCKER_HOST variable each time a bash terminal is opened.

X-Infinite commented 3 years ago

I had the same problem with WSL 2 on debian 10 (without docker desktop). Checking the docker daemon log, the problem seemed from iptables:

time="2020-08-30T18:23:54.858343900+02:00" level=warning msg="Running iptables --wait -t nat -L -n failed with message: iptables v1.8.2 (nf_tables): CHAIN_ADD failed (No such file or directory): chain PREROUTING, error: exit status 4"

So, I changed iptables to legacy mode:

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

Now, It work fine:

$ sudo service docker restart
$ sudo service docker status
[ ok ] Docker is running.

Hope it helps people with the same problem.

I use this way,it's works!!!!!!

williscool commented 3 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

this fixed it for me too... but I had to kill and restart my tmux for it to pick whatever that does up o.o

mnpenner commented 3 years ago

I don't know what's going on here, but Docker Desktop broke my Kubernetes install again. Every time I upgrade, it breaks something.

First it deactivated Kubernetes integration, so I had to re-enable that:

image

WSL integration was still enabled, but make sure that's checked too:

image

docker ps still wouldn't connect from inside WSL though until I checked this:

image

I don't recall if I had that checked or not before, but it stopped working one way or another, or perhaps that's due to the next issue...

I think when Docker Desktop uninstalled Kubernetes by itself, it killed the certificates along with it. So I was also getting errors like this:

Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

So from PowerShell (Windows side) I ran:

cat ~/.kube/config

And then manually copied the docker-desktop cluster and user over into ~/.kube/config inside WSL.

N.B. I have my $DOCKER_HOST set to...

❯ echo $DOCKER_HOST
tcp://0.0.0.0:2375

Which I set awhile back I think because of some WSL networking shenanigans.

Of course it also lost or destroyed all my volumes so now all my test data is gone and my database won't boot.

btshowmetainfo commented 3 years ago

Same problem here. Suddenly, since some recent upgrade, the integration with my Ubuntu 20.04 distro (which IS my default distro...) broke, and I had to manually re-enable it...

PK2W commented 3 years ago

I managed to get docker using WSL2 with Ubuntu 2004 distro right away by following docker desktop documentation, however, I had to use SLES distro for one of my projects and it didn't work - docker wsl2 integration component refused to come up. Docker Desktop threw the following message: image

And within SLES I was getting:

root@sles12sp5:~ # docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:17:50 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

So I followed the workaround provided in this message and managed to make it working by just starting the docker-desktop-proxy process. as was mentioned in the original workaround message I copied exec string from working ubuntu setup:

root@ubuntu2004:~ # ps -aux | grep docker-desktop
root       705  0.0  0.1 1390388 30300 pts/1   Ssl+ 23:16   0:00 /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu-20.04 --docker-desktop-root /mnt/wsl/docker-desktop
root@sles12sp5:~ # docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:17:50 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
root@sles12sp5:~ # /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu-20.04 --docker-desktop-root /mnt/wsl/docker-desktop &>/dev/null &
[1] 4535
root@sles12sp5:~ # docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:17:50 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:15:47 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
root@sles12sp5:~ #

Note that I copy-pasted the exact same exec string from ubuntu, i.e. keeping --distro-name Ubuntu-20.04 parameter untouched , if I try to provide SLES distro name instead, script fails with:

root@sles12sp5:~ # /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name SUSE-Linux-Enterprise-Server-12-SP5 --docker-desktop-root /mnt/wsl/dcker-desktop
INFO[0000] populating cli tools from /mnt/wsl/docker-desktop/cli-tools
...
INFO[0000] creating symlink for /usr/share/zsh/vendor-completions/_docker
INFO[0000] cli tools successfully installed
FATA[0000] creating cross distro service socket: listen unix /mnt/wsl/docker-desktop/shared-sockets/guest-services/distro-services/suse-linux-enterpriseserver-12-sp5.sock: bind: invalid argument
r2DoesInc commented 3 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

To be clear, run these commands in your linux container that is having issues. Then from Windows restart the whole Docker service. not just the app. Right click the icon in your tray and restart. I think for me this was an issue bcause my container was originally a v1 container and the migration doesnt do a good enough job at cleanup.

Thank you @williscool !

rmourey26 commented 3 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. I've had the same issue for months, and ultimately using sudo /mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu --docker-desktop-root /mnt/wsl/docker-desktop upon opening the Ubuntu 20.04 Wsl2 Microsoft store app temporarily fixes the issue.

pappel-ig commented 3 years ago

getting the same error: NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR default * Current DOCKER_HOST based configuration tcp://localhost:2375 https://74.16.92.21:6443 (default) swarm Warning: DOCKER_HOST environment variable overrides the active context. To use a context, either set the global --context flag, or unset DOCKER_HOST environment variable.

zeromask1337 commented 3 years ago

I solved this problem by running sudo service docker start. Its because systemctl doesn't work on wsl and you have to use Sysvinit.

muhammadsheraz commented 3 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

This solution saved me, thanks a lot man!

toreylittlefield commented 3 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

@ldormoy thank you very much! I can confirm this solution worked for me.

GavinRay97 commented 2 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

Thank you so much! This fixed it for me as well:

FWIW, this issue only popped up after explicitly enabling integration with Ubuntu in Docker Desktop settings.

Prior to that, I had only checked Default Distro because I thought that meant Ubuntu, but it did not. So I had been using it without the integration for some time.

Muhannadimad commented 2 years ago

I am running wsl2 (Ubuntu-18.04) and I ran into the same issue.

I solved the problem using: 1- By default your ubuntu doesn't have 'docker engine', and to install it follow these steps: https://docs.docker.com/engine/install/ubuntu/ .

2- Start docker daemon using this command: service docker start .

timothydavis commented 2 years ago

If you are trying to do this without docker desktop on Ubuntu. You can edit your /etc/docker/daemon.json and set the path to unix:///var/run/docker.sock this will make commands work inside of linux shell.

ghost commented 2 years ago

upgrade wsl to wsl2 and restart docker desktop

veysel-dtech commented 2 years ago

If you are trying to do this without docker desktop on Ubuntu. You can edit your /etc/docker/daemon.json and set the path to unix:///var/run/docker.sock this will make commands work inside of linux shell.

@timothydavis thank you very much. this worked for me