Docker Community Forums

Share and learn in the Docker community.

Accessing container by its internal IP from Windows host

beta
docker

(Artoflife) #1

Hi all,

I’m currently playing with Docker version 1.12.2, build bb80604, experimental on Windows 10 Pro.
I have a proxy container, which requires access both from host OS and other containers.

Here’s a part of docker-compose.yml:

browsermobproxy:
 image: userId/browsermob-proxy:2.1.2
 ports:
 - "9090-9191:9090-9191"
 expose:
 - "9090-9191"
 links:
 - seleniumhub:hub_sel
 - chromenode:ch_node

To establish connection with other containers first I’m retrieving proxy’s internal ip via the following script:

@echo off
set PROXY_NAME=
for /f "delims=" %%a in ('docker ps --format "{{.Names}}" ^| findstr "proxy"') do @set PROXY_NAME=%%a

set IP=
for /f "delims=" %%a in ('docker inspect --format "{{.NetworkSettings.IPAddress}}" "%PROXY_NAME%"') do @set IP=%%a
echo %IP%

On Ubuntu 16.04 similar sh script was enough for accessing proxy within host OS. But on Windows 10 I can’t use it for some reason. It always gives me connection refused error. However, when I passed localhost instead of internal ip, I was able to access proxy on default 9090 port.

Does anyone have any idea why the behavior is different on linux / windows? And how to make it works the same way using internal container’s ip?

Thanks,
Sergey


Cannot browse Owin API from localhost, can from External