Closed rugk closed 2 years ago
Host networking and port forwarding are incompatible and if the pod were to be created with --net=host it would not let you add ports to it; by adding net=host only to the container, now the container has not joined the pod's network namespace, and the container service and pod are competing for access to the ports (the pod, being started first, always wins). Podman is doing exactly as podman-compose instructed it to do, and if there is a bug it's in how compose YAML with net=host and port forwarding is handled.
-> The point here seems to be that net
should not be added to the container, but to the pod, podman-compose
adds it to the container only though…
Note I guess the reason this happens is actually the same as https://github.com/containers/podman-compose/issues/316. So feel free to close this as a duplicate of https://github.com/containers/podman-compose/issues/316.
I believe this is resolved in latest code, please confirm, if not reopen please.
and #316 then too?
copied from and originally reported at https://github.com/containers/podman/issues/10882
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When you use host networking and ports together, the systemd units podman generates are broken in such a way that if the ports that are passed via
-p
are actually used/bount inside of the container, the container/service will fail, because they are already in use by an infra container – that previously was not there/block it.Steps to reproduce the issue:
The issue happens when you use
network_mode = "host"
andports
at the same time (I know, ports are ignored then) and let podman generate a systemd unit based on that.For the example to work, you need a simple caddy server that binds on ports 80 and 443… So create a Caddyfile e.g.
So e.g. create a YML
docker-compose.yml
file…Run podman-compose:
Or obviously just run the podman command shown here.
podman generate systemd "caddy" --restart-policy=always --new --name --files
Move files to
$HOME/.config/systemd/user
and enable/start the services.Describe the results you received:
What happens:
Now what happens when you
systemctl --user start pod-caddy.service
is that the caddy service will fail, because it cannot bind to the given ports. The reason is just that the ifra/pod container there already uses the ports it wants to bind.Describe the results you expected:
It should not fail. It did not fail when testing it with
podman-compose
, so now it also should not fail.Additional information you deem important (e.g. issue happens only occasionally):
AFAIK this is not an issue in
podman-compose
, because the spec for docker compose says:So AFAIK, Docker also shows no error if you use these two things together. They should just be silently ignored.
Also if you still argue this is a user error, I'd say that even if it is, it should then consistently fail. I.e. either should the
podman-compose
/podman
start fail initially or nothing should fail. But failing only on the generated systemd services is very bad IMHO and it took me quite some time to troubleshoot/find out what the actual issue here is.Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):As there is no such thing on rpm-ostree
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)
Yes, version is only a minor release/slightly older.
Additional environment details (AWS, VirtualBox, physical, etc.): physical
Fedora CoreOS 34 (stable stream)