0

thought it will be much simpler, but I couldn't find a satisfying solution.

I wish to forward any messages coming from the container on a specific port to the host, but not the opposite(messages coming from the host should not be forwarded to the container).

Setup

  • host, running a web server on port 9880.
  • docker container(on the same host), that should forward any messages on port 9880 on the inner container localhost to the webserver running on the host on port 9880.

image for demonstration enter image description here

Requirements

  • any requests coming from the host/outside world to port 9880 should arrive to the webserver running on the host on port 9880. any request from within the container on port 9880 should be forwarded to webserver on the host as well.

Limitations

  • docker on windows - so no option for 'host' docker network.
  • I would like to rely on the ports only and not on the IP of the containers because this setup is going to be installed on a number of hosts and I prefer a solution that would work always with no need to check it and change configurations.
Eliav Louski
  • 3,593
  • 2
  • 28
  • 52
  • can you give a user senario in which such port faward is useful? i.e. want to know why you need. – Lei Yang Mar 22 '22 at 00:51
  • What have you tried so far? Why is it important to run this in a container; how would you access or use it? (A container usually only runs one process and the host is [generally reachable from containers](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) so you could run HAProxy or Nginx in a dedicated container to provide this functionality but it doesn't seem like it adds anything.) – David Maze Mar 22 '22 at 01:23
  • my question is quite simple: how do I forward specific port from the localhost of the container to the localhost of the host(without the opposite way)? – Eliav Louski Mar 27 '22 at 08:11

0 Answers0