Pierangelo Calanna
Pierangelo Calanna

Reputation: 572

How to access service in localhost exposed on a given port from a nginx container

I currently have a nginx container which points to other dockers, that run a java app, through ip and port, working as expected. For simplicity porpouse, I'm running these java apps outside a docker container, thus having them exposed on localhost:xxxx

When trying to communicate to localhost:xxxx from nginx container, it obviously pointer to the container itself and not my java apps.

Is there a workaround to this problem?

Upvotes: 0

Views: 99

Answers (1)

Leonard Michalas
Leonard Michalas

Reputation: 1188

Localhost is scoped to the container itself. Therefore to be able to connect to it, you would have to be inside the container.

To fix this, you need to get your application to talking/listen to 0.0.0.0 instead.

Upvotes: 1

Related Questions