Docker Community Forums

Share and learn in the Docker community.

Create connection from a socket in Docker container to java app on localhost


We are using Netopeer2 in Docker on Windows 10. It is running with “Call home” function enabled. Function makes server connect to a client socket. This works when we have both client and server running in docker.
However my actual problem is when I have a java program with a server socket running on my host ( Socket listens on port 4334. See below.

$ netstat -a | grep 4334

Then I enable “call home” on Netopeer2 in Docker container but there is no connection to the socket listening on port 4334.

I have started docker container with:

docker run --net host -it --name sysrepo -p 830:830 --rm netopeer2-mod-image:latest

and enabled the call home function but no connection.

Any ideas?


localhost:4334 on the host, is local to your host… and can not be seen from the container.
Try binding you service on the host to it’s ip (or and configure the call home target to the host ip.

Thanks for reply. I could still not get it to work. Is there a way to see what sockets are opened from container?

Don’t care about my last comment. My mistake. I got it working now :slight_smile:

I’m curious about how you solved it.

I know that for Linux containers running on Docker Desktop on Windows or Mac, the local host can be accessed via host.docker.internal instead of localhost.

Is there another solution?