Home > Back-end >  Connect to docker container on windows host from another machine
Connect to docker container on windows host from another machine

Time:10-06

For development purposes I need to be able to connect to a container running tomcat on a Windows host from other machines on the same network. I'm running two containers locally on a bridge network and publishing the ports from each of them when I run them. The applications are accessible via localhost but I can't connect to them via the host's network name or IP, connection is refused. Running netstat on the Windows host I see the tomcat port listening on 127.0.0.1:8080 and [::1]:8080 but that's it. There is no entry for the machine IP or the 0.0.0.0 address.

I'm running the containers with these commands:

docker network create openldap --driver bridge
docker run -d --rm --name openldap -p 1389:1389 --network openldap local-openldap:latest
docker run -p 8080:8080 --env-file local-env --network openldap local-tomcat:latest

I've tried adding the 0.0.0.0 address explicitly to the Tomcat config in server.xml

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
address="0.0.0.0"/>

I've tried adding the 0.0.0.0 address explicitly as part of the publish option when running the container. I ran docker port for the container and see the entries 8080/tcp -> 0.0.0.0:8080 and 8080/tcp -> :::8080 and I've tried running the tomcat container standalone without joining the bridge network I created but nothing has made a difference. To try and isolate to docker I have run a local tomcat instance, not in a container and that is reachable.

Feel like there's something very basic that I'm missing as the docker docs read to me like the publish port option should just do this by default, and I'm not getting any relevant hits from the various searches I've been trying. Think I'm asking the wrong questions.

Additional detail post resolution: this issue was hit running rancher desktop using dockerd as the runtime, which turns out to be the source of the issue.

CodePudding user response:

In case anyone else finds this, turns out it was a rancher-desktop issue which has very recently been fixed https://github.com/rancher-sandbox/rancher-desktop/issues/2677.

Installed the latest development build, which isn't up on the releases page yet, and that took care of the issue.

  • Related