gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 21:36:29 34 4
gpt4 key购买 nike

在 WSL 中成功安装 Docker 后,如果我运行标准 Docker 命令,我会收到连接错误。是否使用 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?

但是,如果我将 -H localhost:2375 添加到命令中,我可以运行 Docker 没有问题。 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

最佳答案

Docker 守护程序无法在 WSL 下运行,因为它没有实现必要的内核 ABI。如果您正在运行 Docker for Windows,您可能正在连接到它管理的 Hyper-V 虚拟机。

因为它位于不同的机器上,所以您将无法将 WSL 目录挂载为 Docker 卷,但您可以从 WSL 目录构建镜像。这是因为在构建时,客户端会创建一个 tarball 并将其发送给守护进程。

关于ubuntu - Docker 是在 WSL 中运行还是连接回 Windows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42516777/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com