Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to docker host from container on Windows 10 (Docker for Windows)

At which IP address can a docker container connect to its host on Docker for Windows (on Windows 10)? How do you find this IP address?

Example: you have a service running at port 1234 on your Windows 10 machine. A program inside your container must access this service. What IP address should the program use to connect to the host?

like image 724
RemiX Avatar asked Nov 22 '16 16:11

RemiX


People also ask

How do I connect to Docker host from inside a Docker container?

Use --network="host" in your docker run command, then 127.0. 0.1 in your docker container will point to your docker host. Note: This mode only works on Docker for Linux, per the documentation.


1 Answers

Short answer: in most cases, you'll need 10.0.75.1 .

In Docker for Windows, the container communicates through a vEthernet adapter called DockerNAT. To find its details, open Command Prompt and type

ipconfig 

Look for an entry that looks like

Ethernet adapter vEthernet (DockerNAT):     Connection-specific DNS Suffix  . :    Link-local IPv6 Address . . . . . : fe80::fd29:297:4583:3ad4%4    IPv4 Address. . . . . . . . . . . : 10.0.75.1    Subnet Mask . . . . . . . . . . . : 255.255.255.0    Default Gateway . . . . . . . . . : 

The IP address to the right of IPv4 Address is the one you need.

Note: make sure the service allows connections from outside your host. As far as that service is concerned, your docker container is a different machine. Also make sure Windows Firewall allows communication to and from the service.

like image 150
RemiX Avatar answered Oct 01 '22 17:10

RemiX