Search code examples
ubuntunetwork-programmingcontainerspodman

Can't expose port for podman pod in macvlan network


I'm using podman 3.4.4 on Ubuntu 22.04 and am trying to setup a pod with a macvlan network. I'm running several other macvlan containers without issues, but when trying to setup a pod (caddy + a backend & a frontend in one pod) I can't expose port 80/443 as they are already exposed.

Setting up the pod:

podman pod create --name baz \
  --network foonet \
  --dns 192.0.2.2 \
  --ip 192.0.2.10 \
  -p 80:80 \
  -p 443:443

foonet:

podman network create -d macvlan\
  -o parent=bridgeexample \
  --subnet 192.0.2.0/24 \
  --gateway 192.0.2.1 \
  --ip-range 192.0.2.0/24 \
  foonet

One of the containers in the pod, exposes port 80/443:

podman create --pod baz \
  --name baz_caddy \
  caddy:latest

The typical error message I've seen:

Apr 11 21:19:37 atomic podman[4039059]: Error: error starting container 30e70a74280cf68b5c92eb7b0f6955ee9c2f53396fe2f7fd1c48964f28ed8738: cannot listen on the TCP port: listen tcp4 :80: bind: address already in use

If I try to expose the port on the IP I've assigned the container (192.0.2.10:80:80) I get:

bind: cannot assign requested address

Any ideas?

Update: larsks was right, trying to export ports when using macvlan is incorrect. I removed the ports and things started working.

Thanks!


Solution

  • larsks solved the issue, I had an accident while thinking I should expose ports for macvlan backed networks.