I am having a problem with docker’s port forwarding mechanism.
I short, the problem can be explained by executing the following tests:
docker run -it -p 1234:1234 ubuntu bash (there is NO service behind port 1234) (in another terminal) u753576@LSYH-u753576l1:~$ nc -z -v 127.0.0.1 1234 Connection to 127.0.0.1 1234 port [tcp/*] succeeded!
We did face this problem when using Apache ActiveMQ Artemis Messaging broker.
When running multiple Artemis instances in separate containers, forming a cluster, Artemis is trying to find out what instances are alive by using some connection mechanism in 'netty’s project. As the connection will be successful (see the netcat example above), Artemis thinks the node is alive.
So netty might be trying the same type of ‘tcp connect scan, without data transfer’ to see if the port is open.
I know that this might be an operating system feature and i also know that docker’s ‘host networking’ does solve the problem.
Still i am wondering if anyone has an alternative solution? (e.g. host networking is not available under Windows)
Please note that i cannot change the way netty is discovering if the probed port is open or not. Telnet obviously will result a connection failure if there is no service running behind the port forward.