Redirect all outgoing HTTP requests of one container to specified port of another container

We have two containers - A and B.
A container makes http request to some http website. What I need is to redirect all these packets to specified port of container B.
I think, that some “voodoo” with iptables should work, but I’m not a specialist in this field. So, please, help me to solve this problem.

P.S. Term “http” in this question is just a placeholder - I’m interested in redirection of any tcp traffic, that is directed to specified port NNN.


Set port forwarding to the IP Address of the container.

Can you please provide me with more detailed description of your proposed solution? For example, give some commands or a link to the docs page.