Skip to content

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

Closed

Description

@mwoodpatrick

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

Activity

  1. zeehjr commented on Nov 7, 2019

    @zeehjr

    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

  2. liyo commented on Nov 7, 2019

    @liyo

    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.

  3. liyo commented on Nov 7, 2019

    @liyo

    Fixed it by switching to Linux containers...

  4. mwoodpatrick commented on Nov 8, 2019

    @mwoodpatrick
    Author
  5. simonferquel commented on Nov 8, 2019

    @simonferquel

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

  6. mwoodpatrick commented on Nov 8, 2019

    @mwoodpatrick
    Author
  7. mikedickey commented on Nov 10, 2019

    @mikedickey

    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?

  8. simonferquel commented on Nov 12, 2019

    @simonferquel

    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 ?

  9. mwoodpatrick commented on Nov 12, 2019

    @mwoodpatrick
    Author
  10. stewartadam commented on Nov 13, 2019

    @stewartadam

    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.

  11. HawkiesZA commented on Nov 19, 2019

    @HawkiesZA

    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.

  12. ilerik commented on Dec 4, 2019

    @ilerik

    @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!

  13. luck02 commented on Dec 13, 2019

    @luck02

    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>
    
  14. flipch commented on Dec 13, 2019

    @flipch

    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?

  15. luck02 commented on Dec 13, 2019

    @luck02

    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.

  16. 78 remaining items

  17. zeromask1337 commented on Sep 2, 2021

    @zeromask1337

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

  18. muhammadsheraz commented on Sep 5, 2021

    @muhammadsheraz

    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!

  19. toreylittlefield commented on Oct 11, 2021

    @toreylittlefield

    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.

  20. GavinRay97 commented on Nov 22, 2021

    @GavinRay97

    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:

    • Docker Desktop: 4.0.0 (67817)
    • Windows: Windows 11 Home Insider Preview 22483.1000, Feature Experience Pack 1000.22483.1000.0
    • WSL: Ubuntu 20.04

    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.

  21. Muhannadimad commented on Jan 21, 2022

    @Muhannadimad

    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 .

  22. timothydavis commented on Jan 26, 2022

    @timothydavis

    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.

  23. veysel-dtech commented on Jun 17, 2022

    @veysel-dtech

    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

  24. eccentricOrange commented on Jul 3, 2022

    @eccentricOrange

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

    I am doing this, but it seems to reset after a reboot of Windows (shutdown /g as in CMD). I turned on integration yesterday, and it's off today morning. I did click "Apply", and some other settings (such as checking for updates in Docker Desktop) persist.

  25. docker-robott commented on Oct 1, 2022

    @docker-robott
    Collaborator

    Issues go stale after 90 days of inactivity.
    Mark the issue as fresh with /remove-lifecycle stale comment.
    Stale issues will be closed after an additional 30 days of inactivity.

    Prevent issues from auto-closing with an /lifecycle frozen comment.

    If this issue is safe to close now please do so.

    Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
    /lifecycle stale

  26. docker-robott commented on Nov 30, 2022

    @docker-robott
    Collaborator

    Closed issues are locked after 30 days of inactivity.
    This helps our team focus on active issues.

    If you have found a problem that seems similar to this, please open a new issue.

    /lifecycle locked

  27. locked and limited conversation to collaborators on Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions