简体   繁体   English

从 VMWare Workstation VM 访问在主机上运行的 Docker

[英]Accessing Docker running on Host machine from VMWare Workstation VM

I have the following setup:我有以下设置:

  • Windows 10 Host (Hyper-V enabled) Windows 10 主机(启用 Hyper-V)
  • Docker Desktop installed on host Docker 桌面安装在主机上
  • VMWare Workstation Pro (16) VMWare 工作站专业版 (16)
  • Windows 10 VM - Docker CLI installed on vm Windows 10 VM - Docker CLI 安装在 vm 上

The Windows 10 VM is used as a dev environment, with project-specific stuff on there. Windows 10 VM 用作开发环境,其中包含项目特定的内容。

I also use the host as a development machine for other projects - so want to be able to use docker on both.我还将主机用作其他项目的开发机器 - 所以希望能够在两者上使用 docker。

What I'd like to do is access the docker engine running on the host, from my VM By access docker, I mean use the docker cli to run containers, build images etc... setting DOCKER_HOST or something like that?我想做的是从我的虚拟机访问在主机上运行的 docker 引擎通过访问 docker,我的意思是使用 docker cli 来运行DOCKER_HOST容器或构建类似的图像?

Is this possible?这可能吗? Or any other way?还是有什么其他方式?

So far, I've set my VM to use NAT networking and tried:到目前为止,我已将我的 VM 设置为使用 NAT 网络并尝试:

docker -H tcp://192.168.126.2:2375 images

Which returns哪个返回

error during connect: Get http://192.168.126.2:2375/v1.40/images/json : dial tcp 192.168.126.2:2375: connectex: No connection could be made because the target machine actively refused it.连接时出错:获取http://192.168.126.2:2375/v1.40/images/json :拨打 tcp 192.168.126.2:2375:无法建立连接,因为目标机器主动拒绝它:无法建立连接

192.168.126.2 is the ip of the default gateway, from within the VM (so - my host?) 192.168.126.2是默认网关的 ip,来自 VM(所以 - 我的主机?)

On the host machine, if I do docker -H tcp://0.0.0.0:2375 images I get the expected result.在主机上,如果我执行docker -H tcp://0.0.0.0:2375 images ,我会得到预期的结果。

On the host machine, I've also set:在主机上,我还设置了:

"hosts": ["tcp://0.0.0.0:2375"],

within the docker engine config:在 docker 引擎配置中: 在此处输入图像描述

so what i would do and usually am doing is in VMware Workstation in Network editor I connect VMs to a bridge and select my main line that provides connectivity whether it is an Ethernet port or Wifi and associate it to lets say VMnet0.所以我会做并且通常正在做的是在网络编辑器中的VMware Workstation中我将VM连接到网桥和select我的主线,它提供连接,无论它是以太网端口还是Wifi,并将其关联到让我们说VMnet0。 Then in VM settings I assign that VM's NIC to VMnet0 and that is how my VM and my host are on same LAN.然后在 VM 设置中,我将该 VM 的 NIC 分配给 VMnet0,这就是我的 VM 和我的主机在同一个 LAN 上的方式。 I would not use NAT.我不会使用 NAT。

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

相关问题 从同样位于 boot2docker vm 内的 Docker 容器以 localhost 身份访问主机 - Accessing host machine as localhost from a Docker container that's also inside a boot2docker vm 想要使用VMWare Workstation 12 Player从macOS VM运行Docker时出现Hyper-V问题 - Hyper-V problems when wanting to run Docker from a macOS VM with VMWare Workstation 12 Player 使用VMWare工作站在静态IP上设置Docker计算机 - Set Docker machine on static IP using VMWare workstation 如何访问在VMWare工作站中运行的tomcat docker容器? - How to access tomcat docker container running in VMWare workstation? 从主机访问在 docker 上运行的服务器 - Access server running on docker from host machine 从不同的 docker 主机访问在 docker 主机中运行的 api - Accessing an api running in a docker host from a different docker host 将在 Ubuntu VM 内运行的 docker 容器端口与 VM 的主机网络连接 - Connect a docker's container port that is running inside an Ubuntu VM, with the VM's host machine network 从Docker容器访问主机的虚拟机 - accessing host's virtual machine from docker container 从LAN连接的PC访问在VM机器上运行的Docker容器 - Access a docker container running on a VM machine from LAN connected PC VMware VM 上的 Docker 网络 - Docker networking on VMware VM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM