[英]Connect to docker container on windows host from another machine
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.出于开发目的,我需要能够从 same.network 上的其他机器连接到在 Windows 主机上运行 tomcat 的容器。 I'm running two containers locally on a bridge.network and publishing the ports from each of them when I run them.
我在 bridge.network 上本地运行两个容器,并在运行它们时从每个容器发布端口。 The applications are accessible via
localhost
but I can't connect to them via the host's.network name or IP, connection is refused.这些应用程序可通过
localhost
访问,但我无法通过主机的网络名称或 IP 连接到它们,连接被拒绝。 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. Windows 主机上的 Running.netstat 我看到 tomcat 端口侦听
127.0.0.1:8080
和[::1]:8080
,仅此而已。 There is no entry for the machine IP or the 0.0.0.0
address.机器 IP 或
0.0.0.0
地址没有条目。
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我尝试将
0.0.0.0
地址显式添加到 server.xml 中的 Tomcat 配置
<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.我尝试在运行容器时将
0.0.0.0
地址显式添加为发布选项的一部分。 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.我为容器运行了 docker 端口,看到条目
8080/tcp -> 0.0.0.0:8080
和8080/tcp ->:::8080
并且我尝试独立运行 tomcat 容器而不加入我创建的 bridge.network 但是什么都没有改变。 To try and isolate to docker I have run a local tomcat instance, not in a container and that is reachable.为了尝试隔离到 docker,我运行了一个本地 tomcat 实例,不在容器中并且可以访问。
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.当 docker 文档读给我听时,我感觉好像缺少一些非常基本的东西,就像发布端口选项应该默认执行此操作一样,并且我没有从我一直在尝试的各种搜索中获得任何相关的匹配项。 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.解决后的其他详细信息:此问题是在使用 dockerd 作为运行时运行 rancher 桌面时遇到的,结果证明这是问题的根源。
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 .万一其他人发现了这个,事实证明这是一个最近已修复的 rancher-desktop 问题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.安装了最新的开发版本,它还没有出现在发布页面上,并且解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.