Connecting to Windows Docker host

Hi,

I’m having issues connecting from docker container to host VM.

VM image: windows-latest (the public image)
Docker image: aspnet:4.8-windowsservercore-ltsc2019

Integration test setup:
Spins up Http listener in host VM (random port 50 000+) eg 50300
Opens port in Windows firewall
Spins up Windows Server container with a web service
Web service makes a request to Http listener in host VM

Docker network:
docker network create -d nat --gateway 192.168.0.1 --subnet 192.168.0.0/24 --name integration-tests

Container:
docker run --network integration-tests -e LISTENER_ENDPOINT=http://192.168.0.1:50300 -p 8080:80 my-web-sample:latest

Observed result:
Github Actions - host is not reachable
Local lab - host is reachable

So I guess I’m skipping some limitation on Github Actions?

1 Like

Hey, @RassK
Could you please add a firewall rule to allow to connect to a port?

jobs:
  tests:
    runs-on: windows-latest

    steps:
      - run: |
          New-NetFirewallRule -DisplayName "Allow port 23456" -Direction Inbound -LocalPort 23456 -Protocol TCP -Action Allow -Profile Any
      - name: Test port 23456
        shell: cmd
        run: |
          start node -e "require('http').createServer(function (req, res) { res.end('OK'); }).listen(23456);"
          docker network create -d nat --gateway 192.168.0.1 --subnet 192.168.0.0/24 integration-tests
          docker run --network integration-tests mcr.microsoft.com/windows/nanoserver:1809 curl -v http://192.168.0.1:23456

Yep, my integration tool opens a dynamic port in the firewall for a test runtime. This issue was present also locally, so I could identify it early.

Must be something else :worried:

I don’t think the issue related to github hosted agents, time to start fix opentelemetry-dotnet-instrumentation/AspNetTests.cs at 7cb6863e23671da3d1fa625a76ec210b574c9250 · RassK/opentelemetry-dotnet-instrumentation · GitHub test.

Sorry, I didn’t catch where did you refer?

I’m taking brand new server installation, deploying the code and running tests - all fine.
Running locally in the development machine - all fine.
Running in Github host - no connection between host and container.

@RassK , How do you check connection between docker container & docker host?