Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get IP Address of Docker Desktop VM?

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.

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.

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)

like image 419
Sammi3 Avatar asked Dec 07 '22 11:12

Sammi3


1 Answers

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:

Added by Docker Desktop

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

like image 66
Homer Avatar answered Feb 23 '23 00:02

Homer