简体   繁体   English

从另一台机器连接到 windows 主机上的 docker 容器

[英]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:80808080/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.

相关问题 从远程计算机(而不是容器主机)建立到Windows docker容器的PSSession - Establish PSSession to Windows docker container from remote machine (not container host) Windows上的Docker:如何使用容器IP从主机连接到容器? - Docker on Windows: how to connect to container from host using container IP? 如何从主机外部(同一网络)连接到 docker 容器 [Windows] - How to connect to a docker container from outside the host (same network) [Windows] 将数据从Docker容器持久保存到主机 - Persist data from docker container to host machine 在Windows上的Docker容器中访问主机 - Access a host from within a Docker container on Windows 如何从 Windows 机器中的 Docker 容器内部连接到本地主机上的 MySQL 服务器? - How to connect to MySQL server on localhost from inside of a Docker container in a windows machine? 从 Windows Docker 主机连接到 dockerized postgres - Connect to dockerized postgres from Windows Docker host 如何从 windows Z05B6053C415A2134EAD6 容器中的 .NET 应用程序连接到在主机上运行的 SQL 服务器 - How do you connect to SQL Server running on the host from a .NET app in a windows docker container Docker 容器内的 SpringBoot 无法连接到 Windows 机器上的本地主机 MySQL - SpringBoot within Docker Container cannot connect to localhost MySQL on Windows machine 如何从 Windows 主机上的 docker 容器内部执行 docker 命令 - how to execute docker command from inside docker container on windows host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM