Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing ports to host via port-mapping within QM does not work #714

Open
raballew opened this issue Feb 5, 2025 · 0 comments
Open

Publishing ports to host via port-mapping within QM does not work #714

raballew opened this issue Feb 5, 2025 · 0 comments
Labels
bug Something isn't working centos-sig-automotive Issues related to containers running in centos-sig-automotive

Comments

@raballew
Copy link
Contributor

raballew commented Feb 5, 2025

If you have to run multiple applications all listening on the same port within QM that expose a service to another host an intuitive approach to this would be using port mapping (8080:80, 8081:80) to resolve any conflicts and then publishing those ports:

Example: Port mapping does not work

Within QM /etc/containers/systemd/nginx-1.container:

[Container]
Image=localhost/nginx
PublishPort=8080:80

Within QM /etc/containers/systemd/nginx-2.container:

[Container]
Image=localhost/nginx
PublishPort=8081:80

On the host /etc/containers/systemd/qm.container.d/publish-port.conf:

[Container]
PublishPort=8080:8080
PublishPort=8081:8081

But this does not work even though the QM container publishes those ports.

curl 127.0.0.1:8080
curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused

Instead one has to use host networking which disables port-mapping and therefore only one application can be started as they both would try to bind the same port:

Example: Only one application starts

Within QM /etc/containers/systemd/nginx-1.container:

[Container]
Image=localhost/nginx
Network=host

Within QM /etc/containers/systemd/nginx-2.container:

[Container]
Image=localhost/nginx
Network=host

On the host /etc/containers/systemd/qm.container.d/publish-port.conf:

[Container]
PublishPort=80

One application does not start:

podman ps -a
CONTAINER ID  IMAGE                                            COMMAND               CREATED         STATUS                     PORTS                 NAMES
538e1cf144d9  docker.io/library/nginx:latest                   nginx -g daemon o...  10 seconds ago  Up 10 seconds              80/tcp                frosty_poitras
afe9e0622fc1  docker.io/library/nginx:latest                   nginx -g daemon o...  6 seconds ago   Exited (1) 4 seconds ago   80/tcp                goofy_ellis
@Yarboa Yarboa added bug Something isn't working centos-sig-automotive Issues related to containers running in centos-sig-automotive labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working centos-sig-automotive Issues related to containers running in centos-sig-automotive
Projects
None yet
Development

No branches or pull requests

2 participants