I've seen several variants of this apparently common scenario but all the offered solutions are specific to each case (for example, if the service you want to share is say, MySQL, share the sock file).
I have a service on the host. For simplicity's sake let's say it's netcat listening on 127.0.0.1:5000 TCP.
I need to connect from a container to that address using another netcat, or telnet, and be able to send and receive data.
The host service needs to be in 127.0.0.1 (and not another IP) for a few reasons (including security) and the service is unable to bind to more than one interface. Using 0.0.0.0 is really not an option.
In theory this seems like something that IP tables should be able to solve, but I haven't been able to get it to work, so I assume it's Docker filtering out packets before the rules in the host have a chance to process them (iptables logging doesn't show any packet being received in the host).
Edit: If possible I'd like to avoid the host network driver.