I have the following situation. I have a service that listens to 127.0.0.1 on port 1234 (This cannot be changed for security reasons). On the same machine run a docker container. I need to somehow connect to the service on the host from within the container. Because the service only accepts requests from 127.0.0.1, i need somehow to link the port from the container to the host port but in reverse so when i connect from within the container to 127.0.0.1:1234 the service on the host will receive the data.
Is this possible?
Thanks.
Asked
Active
Viewed 70 times
0

Mr T.
- 4,278
- 9
- 44
- 61
2 Answers
2
With the default bridged network, you won't be able to connect from the container to a service on the host listening on 127.0.0.1. But you can use --net=host
when running a container to use the host network stack directly in the container. It removes some of the isolation, but then allows you to talk directly to 127.0.0.1 as the container and talk to services running on the host.

BMitch
- 231,797
- 42
- 475
- 450
-2
Question
How to bind Dockerized service on localhost:port ?
Answer
Use the -p
as this: docker run -p 127.0.0.1:1234:1234 <other options> <image> <command>
.

Auzias
- 3,638
- 14
- 36