skip to Main Content

I have two separate spring web projects one is on my computer and other is in a docker container. What im trying to do is exposing both of them in 8080 port. Is there anyway that i can achieve this?

I have a security config file on the project that is in my computer which filters the requests and asks for jwt. So i think i cant directly use a gateway.

2

Answers


  1. Docker container in itself has its own networking and a range of ports. From you computer You NEED to have a port (Source port) which you need to forward to a port inside your docker container (Destination Port). So if that mapping is their and your docker container is running. The source port is on your computer is already listening for incoming request so that it can forward it to the Docker Container.

    And once a port is already utilized you cannot reuse it parallely to listen to another application/service.

    Answering to your question as per my experience It cannot be done or atleast their is no straightforward way to do it.

    Other answers are welcome. Thanks

    Login or Signup to reply.
  2. You can easily do this if you add a secondary IP to your NIC and tell both applications to only listen on one of it.

    How to do that depends on your OS. Here e.g. is a manual for ubuntu.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search