Socket connection in Docker initially succeeds

Running under MacOS I connect from the node.js application with net.Socket () to the Docker container running on the same host that contains the C ++ socket server under Centos. Docker Launch Command:

docker run -it --rm -p 14000-14010:14000-14010 -v /Users/me/Development/spdz:/spdz spdz/spdzdev 

When the C ++ server in docker does not work, I see a successful connection in node, and then after 3 ms through a closed socket message.

It seems that the proxy in front of the container accepts the request, passing it to the docking station, where it is rejected. However, this leads to erroneous messages in my front-end application, which considers that the connection was successful, only to find out later that it is not.

I want a simple connection to be rejected. Any suggestions as to how this could be fixed or better understood would be helpful.

I am sure that the behavior introduced by Docker, since running components outside of Docker gives the expected immediate connection failure. I also tried to map the exported ports to an external network interface, not localhost, but to see the same behavior.

+7
docker sockets
source share
1 answer

I suggest you check if the error does not come from your server application.

You can use the netcat command line to open a socket in the Docker nc -l 14000 container. This will create a TCP server socket listening on port 14000.

Then from your computer (MacOs) open a terminal and try connecting to telnet telnet -eq localhost 14000

0
source share

All Articles