无法使用 podman 公开端口

Can't expose port with podman

我正在尝试完成在 docker/podman 容器实例中启动应用程序的教程。

我尝试过使用 -p port:port 和 --expose port 但似乎都不起作用。

我已使用 ss -an 确保看到端口处于侦听状态。

我已确定没有任何其他尝试绑定到该端口。

无论我做什么,我都打不中localhost:port或ip_address:port。

我觉得我从根本上错过了一些东西,但不知道下一步该去哪里。

任何有关尝试的建议或要审查的文档的任何建议都将不胜感激。

谢谢,

肖恩

公开:(Reference)

Expose tells Podman that the container requests that port be open, but does not forward it. All exposed ports will be forwarded to random ports on the host if and only if --publish-all is also specified

根据容器文件的 Redhat 文档,

EXPOSE indicates that the container listens on the specified network port at runtime. The EXPOSE instruction defines metadata only; it does not make ports accessible from the host. The -p option in the podman run command exposes container ports from the host.

要指定端口号,

The -p option in the podman run command exposes container ports from the host.

示例:

podman run -d -p 8080:80 --name httpd-basic quay.io/httpd-parent:2.4

在上面的示例中,端口号 80 是容器 listens/exposes 的端口号,我们可以通过端口号 8080

从容器外部访问它