【问题标题】:Docker container ports are exposed on Windows but not UbuntuDocker 容器端口在 Windows 上公开,但在 Ubuntu 上不公开
【发布时间】:2019-09-09 21:13:14
【问题描述】:

我正在使用 Docker Desktop 的 Windows 10 机器上开发 基于 Ubuntu 的 docker 映像。该映像有一个服务器应用程序在端口 5000 上侦听 HTTP 流量。当我在 Windows 上本地运行映像时,使用:

docker run -d -p 5000:5000 dockerImageName /opt/serverApp

一切正常,我可以去http://localhost:5000查看网页界面。

但随后我将映像推送到 Azure 中的存储库,然后将其拉回 Ubuntu Azure VM 并执行相同的命令,容器似乎可以正确启动但正在执行:

curl http://localhost:5000

返回:

curl: (7) 无法连接到 localhost 端口 5000:连接被拒绝

没关系,但我还允许在 VM 所连接的网络安全组中的端口 5000 上传入流量。

如果我执行:

sudo lsof -i:5000

什么都不返回。

这是与 Azure 相关的问题吗? Linux 映像在 Windows 上的运行方式与在 Azure 上的 VM 的运行方式(在 Windows Docker Desktop 上使用 Linux VM 运行容器)之间是否存在差异?

【问题讨论】:

    标签: docker port


    【解决方案1】:

    Le 叹了口气是这样的: Docker container will automatically stop after “docker run -d”

    在运行容器时,Windows 和 Ubuntu 之间的行为变化令人烦恼。

    【讨论】:

      猜你喜欢
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多