Nico
Nico

Reputation: 123

Podman container on server only reachable if using network option host

I want to run two containers on the same server via podman.

  1. A frontend server that should be reachable from the internet via <server_ip>:4200
  2. A backend server that should be reachable from by the webserver via localhost:8000

The following works on my local pc but not on the server:

  1. Create a pod that will contain the two containers, so the frontend can reach the backend using localhost and publish the ports 4200 and 8000:

podman pod create -p 4200:4200 -p 8000:8000 --name=mypod

  1. Run both containers inside the pod:

podman run --pod=mypod <frontend_image_id>

podman run --pod=mypod <backend_image_id>

When doing the same on the server I the containers are not reachable from outside the server via <server_ip>:4200 or <server_ip>:8000. From inside the server, e.g. via curl localhost:4200 the containers are reachable.

What also works is deploying containers on the server using the network option host as follows.

podman run --network host <image_id>

In that case, the containers are reachable via <server_ip>:4200 or <server_ip>:8000 from the outside but don't reach each other via localhost.

I must be missing something here, please help or explain this behavior.

Upvotes: 0

Views: 2023

Answers (1)

kobexkawhi
kobexkawhi

Reputation: 21

Saw this in another thread sometime ago , but have you checked your firewall config ?

If your running a redhat dist (fedora, centos, rhel) , try add the ports to your firewall. Run this as root.

firewall-cmd --add-port=4200/tcp --permanent 
firewall-cmd --add-port=8000/tcp --permanent 
firewall-cmd --reload

I had the same issue when running podman as non root user and that worked for me.

Upvotes: 1

Related Questions