K
K
kot25662018-03-19 17:39:04
PowerShell
kot2566, 2018-03-19 17:39:04

Docker: How to link two TCP applications (one in the host system, the other inside the docker container)?

Given:
windows server 2016,
docker for windows,
two C# console applications (server and client) communicating via TCP (originally at 127.0.0.1:9595).
The client is inside a docker container (based on microsoft/windowsservercore), the server is on the main system.
There is no way to get them to communicate with each other.
Procedure:
1)

Dockerfile

FROM microsoft/windowsservercore
ADD . /
ENTRYPOINT ExampleTcpClient.exe

2) "docker run --rm myconsole"
3) The client throws an exception:
No connection could be made because the target machine actively refused it 127.0.0.1:9595

I watched this topic https://stackoverflow.com/questions/40746453/how-t... I
got ip 172.18.112.1 using the ipconfig command.
In this case, the Client throws an exception:
A connection attempt failed because the connected party did not properly respond after a period of time, o
r established connection failed because connected host has failed to respond 172.18.112.1:9595

I tried the options:
server - 127.0.0.1:9595, client - 127.0.0.1:9595
server - 127.0.0.1:9595, client - 172.18.112.1:9595
server - 172.18.112.1:9595, client - 172.18.112.1:9595
Kitematic screenshot
5aafcb0a5b08a792646685.png
How to set up correctly?
ps How to connect the same applications if the Server is also placed inside the container?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Komarov, 2018-03-19
@maNULL

network settings

O
OnYourLips, 2018-03-19
@OnYourLips

The client should not go to 127.0.0.1, but to an external URL (by default, this is 172.17.0.1.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question