运行 docker Ubuntu 18.04.2 LTS
Running docker on Ubuntu 18.04.2 LTS
正如 Microsoft blog, docker is supported on WSL2 now. I am trying to install docker on Linux Subsystem for Windows10. After following all the steps mentioned in this official documentation 所宣布的,我遇到了以下错误。
$docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
$ docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:05 2019
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
我在这里遗漏了什么吗?
您不能 运行 WSL 内部的 docker 守护进程,这意味着您不能在 WSL 内部托管容器。但是您可以使用 WSL 内部的 docker 客户端 运行ning 连接到 windows 上的守护进程 运行ning。
首先,您需要为 windows https://docs.docker.com/docker-for-windows/install/
获取 docker 桌面
完成此操作后,请确保在不使用 TLS 的情况下在 tcp://localhost:2375 上公开守护程序的设置已打开。
然后在 WSL
中安装 docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
并设置 env 变量,以便所有 docker 命令进入 windows
中公开的守护进程
export DOCKER_HOST=tcp://localhost:2375
您现在可以在 WSL 中使用 docker 命令了:-)
Docker is now supported on WSL2
在 WSL2
上成功 运行ning docker 的先决条件
- Windows 10(内部版本 18932 或更高版本)。检查 OS 构建版本
Win-Key + R, run command "winver"
- 您可以通过注册 windows insider program 获取 Build#18932,然后在您的机器上查看最新的 windows 更新
- Enable WSL on your machine( Windows10 ) 然后 运行
wsl --set-default-version 2
使用 Powershell 命令上的管理员始终在您的计算机上使用 WSL2
现在您已准备好在您的机器上安装 Linux 发行版。 Install Ubuntu on Windows 10 WSL 使用这些说明
您需要使用 sudo /etc/init.d/docker start
显式启动 docker
验证安装后一切正常; 运行 Powershell 上的以下命令。如果它显示在输出下方,则意味着 Ubuntu-18.04 在 WSL 2
上是 运行ning
PS> wsl -l -v
NAME STATE VERSION
* Ubuntu-18.04 Running 2
要让 wsl2 与 docker、
一起工作,您还需要做一些调整和步骤
如果您想了解更多有关如何实现此功能的信息,请查看 https://codingfullstack.com/cloud/docker-installation-wsl2/。
正如 Microsoft blog, docker is supported on WSL2 now. I am trying to install docker on Linux Subsystem for Windows10. After following all the steps mentioned in this official documentation 所宣布的,我遇到了以下错误。
$docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
$ docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:05 2019
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
我在这里遗漏了什么吗?
您不能 运行 WSL 内部的 docker 守护进程,这意味着您不能在 WSL 内部托管容器。但是您可以使用 WSL 内部的 docker 客户端 运行ning 连接到 windows 上的守护进程 运行ning。
首先,您需要为 windows https://docs.docker.com/docker-for-windows/install/
获取 docker 桌面完成此操作后,请确保在不使用 TLS 的情况下在 tcp://localhost:2375 上公开守护程序的设置已打开。
然后在 WSL
中安装 dockercurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
并设置 env 变量,以便所有 docker 命令进入 windows
中公开的守护进程export DOCKER_HOST=tcp://localhost:2375
您现在可以在 WSL 中使用 docker 命令了:-)
Docker is now supported on WSL2
在 WSL2
上成功 运行ning docker 的先决条件- Windows 10(内部版本 18932 或更高版本)。检查 OS 构建版本
Win-Key + R, run command "winver"
- 您可以通过注册 windows insider program 获取 Build#18932,然后在您的机器上查看最新的 windows 更新
- Enable WSL on your machine( Windows10 ) 然后 运行
wsl --set-default-version 2
使用 Powershell 命令上的管理员始终在您的计算机上使用 WSL2
现在您已准备好在您的机器上安装 Linux 发行版。 Install Ubuntu on Windows 10 WSL 使用这些说明
您需要使用 sudo /etc/init.d/docker start
验证安装后一切正常; 运行 Powershell 上的以下命令。如果它显示在输出下方,则意味着 Ubuntu-18.04 在 WSL 2
上是 运行ningPS> wsl -l -v
NAME STATE VERSION
* Ubuntu-18.04 Running 2
要让 wsl2 与 docker、
一起工作,您还需要做一些调整和步骤如果您想了解更多有关如何实现此功能的信息,请查看 https://codingfullstack.com/cloud/docker-installation-wsl2/。