Just in case someone ends here having similar issue using ubuntu 24 and docker desktop:
My issue was due to a default configuration value in docker-desktop that needs to be activated to use network_mode: host
.
Just activate Enable host networking
, pretty clear instructions on the UI :) (I just was struggling with this for days)