简体   繁体   English

Docker是在WSL中运行还是连接回Windows?

[英]Is Docker running within WSL or connecting back to Windows?

After successfully installing Docker in WSL, if I run standard Docker commands, I get connection errors. 在WSL中成功安装Docker后,如果我运行标准的Docker命令,则会出现连接错误。 Runing with sudo or not yields the same result in all examples. 在所有示例中,使用sudo运行或不运行会产生相同的结果。

root@SUR002731165154:~# sudo docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

root@SUR002731165154:~# sudo docker version
Client:
Version:      1.13.1
API version:  1.26
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 06:42:29 2017
OS/Arch:      linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

However, if I add -H localhost:2375 to the command I can run Docker no problem. 但是,如果我将-H localhost:2375添加到命令我可以运行Docker没问题。 Is Docker connecting to my localhost Windows 10 machine or is it running locally on WSL, or is doing a bit of both? Docker是连接到我的localhost Windows 10计算机还是在WSL上本地运行,或者两者兼而有之?

root@SUR002731165154:~# docker -H localhost:2375 version
Client:
Version:      1.13.1
API version:  1.26
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 06:42:29 2017
OS/Arch:      linux/amd64

Server:
Version:      1.13.1
API version:  1.26 (minimum version 1.12)
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 08:47:51 2017
OS/Arch:      linux/amd64
Experimental: true

root@SUR002731165154:~# docker -H localhost:2375 info
Containers: 11
Running: 0
Paused: 0
Stopped: 11
Images: 8
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.8-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934 GiB
Name: moby
ID: 4LYM:R5T5:6CPZ:Z2KC:YQ4R:NGN4:V6SR:DF7E:YPYO:7FHY:EQW5:2T7W
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 13
Goroutines: 21
System Time: 2017-02-28T18:54:13.7726687Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

The Docker daemon can't run under WSL as it doesn't implement the necessary kernel ABI's. Docker守护程序无法在WSL下运行,因为它没有实现必要的内核ABI。 If you're running Docker for Windows, you are probably connecting to the Hyper-V virtual machine that it manages. 如果您正在运行Docker for Windows,您可能正在连接到它管理的Hyper-V虚拟机。

Because it's on a different machine, you will not be able to mount WSL directories as Docker volumes, but you can build images from a WSL directory. 因为它位于不同的计算机上,所以您将无法将WSL目录挂载为Docker卷,但您可以从WSL目录构建映像。 This is because on a build, the client creates a tarball and sends it to the daemon. 这是因为在构建时,客户端会创建一个tarball并将其发送到守护程序。

This is a workaround which is to use Docker on windows in WSL instead. 这是一种解决方法,即在WSL中的Windows上使用Docker。

Just add the following to your WSL .bashrc file. 只需将以下内容添加到WSL .bashrc文件即可。

export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PATH="$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin"
alias docker=docker.exe
alias docker-compose=docker-compose.exe

Reference: https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/ 参考: https//blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Docker Windows WSL Ubuntu连接到VMware Ubuntu - Connecting Docker Windows WSL Ubuntu to VMware Ubuntu 从 Windows 主机连接到 wsl2 Ubuntu docker - Connect to wsl2 Ubuntu docker from Windows host 在 Windows 10 Home 中在 WSL 上设置 docker 的问题 - Issue with setting up docker on WSL in Windows 10 Home 如何以 Windows 格式更改 Ubuntu WSL 中的目录? - How to change directory within Ubuntu WSL in Windows format? 在 Windows 中从 ubuntu wsl 运行 pyspark,错误:找不到 cmd - pyspark running from ubuntu wsl in windows, error: cmd not found 无法更新在 Windows 中运行的 wsl2 上的 Linux 11 - Unable to update Linux on wsl2 running in Windows 11 从 WSL 2/Ubuntu sqlcmd 连接到在 Windows 主机上运行的 SQL Server - Connect to SQL Server running on Windows host from a WSL 2/Ubuntu sqlcmd 如何使wsl2在Windows 10上从停止状态变为运行状态 - How to make wsl2 from stopped to running on Windows 10 从在 windows wsl 上托管的 ubuntu 中运行的容器调用在 windows 上运行的 nodejs 应用程序 - calling nodejs application running on windows from container running in ubuntu hosted on windows wsl 问题将 pyodbc 连接到 WSL2 的 Windows 10 Pro 上的 MS SQL 数据库 - > Ubuntu 20.04 - Issue connecting pyodbc to MS SQL database on Windows 10 Pro from WSL2 -> Ubuntu 20.04
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM