如何获取Docker Desktop VM的IP地址? [英] How to get IP Address of Docker Desktop VM?

查看:1988
本文介绍了如何获取Docker Desktop VM的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所在的团队中,我们中有些人使用docker工具箱,而某些用户使用docker桌面.我们正在编写一个需要与开发中的docker容器通信的应用程序.

I'm in a team where some of us use docker toolbox and some user docker desktop. We're writing an application that needs to communicate to a docker container in development.

在docker工具箱上,我知道docker-machine env命令设置了docker主机环境变量,我可以使用它来获取运行docker引擎的虚拟机的ip.从那里,我只访问裸露的端口.

On docker toolbox, I know the docker-machine env command sets the docker host environment variable and I can use that to get the ip of the virtual machine that's running the docker engine. From there I just access the exposed ports.

在Docker桌面上获取该信息的等效方法是什么? (我没有一台具有docker桌面的机器,只有docker工具箱,但是我正在编写应该能够访问这两个容器的Docker的代码)

What's the equivalent way to get that information on docker desktop? (I do not have a machine that has docker desktop, only docker toolbox but I'm writing code that should be able to access the docker container on both)

推荐答案

在Windows操作系统上,安装docker后,docker在主机文件(C:\ Windows \ System32 \ drivers \ etc \ hosts)中添加了一个条目,其IP地址为:

On windows OS, after installed docker, there is an entry added by docker inside your hosts file (C:\Windows\System32\drivers\etc\hosts), which states the IP as:

10.xx.xx.xx host.docker.internal

10.xx.xx.xx host.docker.internal

这篇关于如何获取Docker Desktop VM的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆