0

I am running a web API on the host system and it's not exposed on public IP. I want to access from a docker windows container running on the same system.

By initial analysis, it seems windows container does not support to access host system from within a container.

Tried to access API with the following address but on none of them are working.

https://host_system_ip:port/api/controller/action
https://default_gateway_ip:port/api/controller/action
https://localhost:port/api/controller/action
https://127.0.0.1:port/api/controller/action

For security reasons I cannot make that API to be accessed on public IP, the only host system and containers running on same host machine should be allowed to access web API.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
vivek jain
  • 291
  • 3
  • 13

1 Answers1

0

This works fine for me from within container. Make sure you are on latest OS etc and nothing is missing.

PS C:\> docker run --rm microsoft/windowsservercore powershell invoke-webrequest 192.168.1.221 -useBasicParsing


StatusCode        : 200
StatusDescription : OK
Content           : Application 995184 and started on 3/21/2018 8:59:09 AM
RawContent        : HTTP/1.1 200 OK
                    Content-Length: 54
                    Cache-Control: private
                    Content-Type: text/html; charset=utf-8
                    Date: Wed, 21 Mar 2018 14:01:22 GMT
                    Server: Microsoft-IIS/10.0
                    X-AspNet-Version: 4.0.30319
                    X-Pow...
Forms             :
Headers           : {[Content-Length, 54], [Cache-Control, private],
                    [Content-Type, text/html; charset=utf-8], [Date, Wed, 21
                    Mar 2018 14:01:22 GMT]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        :
RawContentLength  : 54



PS C:\> ipconfig

Windows IP Configuration


Ethernet adapter vEthernet (nat):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::94d6:434:c0b6:8fdc%56
   IPv4 Address. . . . . . . . . . . : 172.29.112.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

Ethernet adapter vEthernet (Internet):

   Connection-specific DNS Suffix  . : lan
   Link-local IPv6 Address . . . . . : fe80::342a:be30:c7c:c1de%24
   IPv4 Address. . . . . . . . . . . : 192.168.1.221
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Gregory Suvalian
  • 3,566
  • 7
  • 37
  • 66