简体   繁体   中英

Can't expose port with podman

I am trying to walk through a tutorial that brings up an application in a docker/podman container instance.

I have attempted to use -p port:port and --expose port but neither seems to work.

I've ensured that I see the port in a listen state with ss -an.

I've made sure there isn't anything else trying to bind to that port.

No matter what I do, I can never hit localhost:port or ip_address:port.

I feel like I am fundamentally missing something but don't know where to look next.

Any suggestions for things to try or documentation to review would be appreciated.

Thanks,

Shawn

As per Redhat documentation for Containerfile,

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 .

To specify Port Number,

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

Example:

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

In above example, Port # 80 is the port number which Container listens/exposes and we can access this from outside the container via Port # 8080

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM