Docker未在Ubuntu WSL上运行-无法通过unix:///var/run/docker.sock连接到Docker守护程序。泊坞窗守护程序正在运行吗? [英] Docker not running on Ubuntu WSL - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
问题描述
我正在Windows 10计算机上运行WSL 2(Ubuntu)。我使用官方Docker指南(
...从默认的WSL2
基于本文。
带有WSL 2,Docker桌面的Windows上的Linux开发环境
和docker docs。
Docker桌面WSL 2后端
以下仅对WSL1有效
似乎docker无法在WSL内运行。他们建议将WSL连接到在Windows中运行的Docker桌面:为Windows和WSL设置Docker
在Docker论坛中,他们也提到了这一点。解决方案:无法连接到docker daemon
希望有帮助。
I am running WSL 2 (Ubuntu) on a Windows 10 machine. I installed Docker on my Ubuntu using the official Docker guide (https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository). Running docker run hello-world
produces the following error: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
.
I have tried the following steps:
- Using
sudo docker...
instead ofdocker...
- Adding user to docker usergroup with
sudo usermod -aG docker $(whoami)
sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
which I found in this thread: https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-is-the-docker-daemon-running-on-this-host/8925/4
None of these steps helped.
docker version
produces this output:
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
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
service docker status
gives Docker is not running
. service docker start/restart
does nothing, Docker does not start. Any ideas what could be the issue?
I found your question, as I was trying to achieve the same. {I have updated my question as with the latest windows update, the process it's much more easier}
Using WSL2
You simply have to activate and use WSL2, I have to install Ubuntu 20.04 as the 18.04 wasn't connecting with Docker desktop. In the windows shell:
To check the WSL mode, run
wsl -l -v
To upgrade your existing Linux distro to v2, run:
wsl --set-version (distro name) 2
WSL Integration will be enabled on your default WSL distribution. To change your default WSL distro, run
wsl --set-default <distro name>
Then in docker you have to.
...use the WSL2 engine
...access from your default WSL2
Based on this article. A Linux Dev Environment on Windows with WSL 2, Docker Desktop And the docker docs. Docker Desktop WSL 2 backend
Below is valid only for WSL1
It seems that docker cannot run inside WSL. What they propose is to connect the WSL to your docker desktop running in windows: Setting Up Docker for Windows and WSL
In the docker forums they also refer to that solution: Cannot connect to the docker daemon
Hope that helps.
这篇关于Docker未在Ubuntu WSL上运行-无法通过unix:///var/run/docker.sock连接到Docker守护程序。泊坞窗守护程序正在运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!