当前位置: 首页 > 面试题库 >

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

上官思博
2023-03-14
问题内容

在WSL中成功安装Docker之后,如果我运行标准Docker命令,则会出现连接错误。在所有示例中,使用sudo或不使用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是连接到我的本地主机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守护程序无法实现必要的内核ABI,因此无法在WSL下运行。如果您正在运行Windows的Docker,则可能正在连接到它管理的Hyper-
V虚拟机。

因为它在另一台机器上,所以您将无法将WSL目录作为Docker卷挂载,但是可以从WSL目录构建映像。这是因为在构建中,客户端会创建一个tarball并将其发送到守护程序。



 类似资料:
  • 问题内容: 我在本地计算机上设置了一个单节点Kafka Docker容器,如Confluent文档中所述(步骤2-3)。 另外,我还公开了Zookeeper的端口2181和Kafka的端口9092,以便能够从在本地计算机上运行的客户端连接到它们: 问题: 当我尝试从主机连接到Kafka时,连接失败,因为它。 这是我的Java代码: 例外: 问题: 如何连接到在Docker中运行的Kafka?我的代

  • 是否有理由使用启动一个文件,或者您应该只使用? 我知道可以启动一个特定的容器,但我指的是在不指定容器的情况下使用它以启动所有yml容器的情况。

  • 没问题,只需将Docker守护进程配置为使用。那么您就可以完全按照本指南的其余部分进行操作了。 如果您沿着这条路走下去,我强烈建议您使用VMware Player滚动您自己的VM,而不是使用Docker工具箱,因为VirtualBox有疯狂的edge case共享文件夹错误,在某个时候会毁了您的生活。别担心,VMware播放器是免费的。只需谷歌如何在VMware Player上设置Ubuntu16

  • 我的docker撰写文件如下所示: 如果我在浏览器中键入http://localhost:15672,我将获得Rabbitmq界面,但是如果我试图像这样从我的探索项目连接: 然后它在队伍中断了 错误是说 ExtendedSocketException:连接被拒绝127.0。0.1:5672系统。网插座。插座EndConnect(IAsyncResult异步结果) ConnectFailureExc

  • 我在docker compose yml文件中为广告侦听器配置了以下配置 警告O.apache.kafka.clients.networkclient-获取相关id为1的元数据时出错:{foo=leader_not_available} 主机可以从我的机器ping,因为它都在同一个网络中,没有防火墙问题。在docker容器中使用命令时,可以看到相同的主机名。我是不是漏掉了什么?

  • 跑步的时候 sudo docker拉Centos 它给连接超时,当它在代理后面运行时,代理已被设置http_proxy 2014/11/10 23:31:53获取https://index.docker.io/v1/repositories/centos/images:拨号tcp 162.242.195.84:443:连接超时