Docker Community Forums

Share and learn in the Docker community.

How to connect with my server inside container

(Aholody) #1

I have created a tcp server with java which is listening on port 1111. This server is running inside my container. My Client which need host and port is running outside the container. Now how can I connect my Client with the Server running inside a container?

Edit: solved the problem.

(Rik) #2


You need to map the container port to a port on the host and connect your client to that port.

In the command to start up the container add the flag “-p [hostport]:1111”

The client can now connect to port [hostport] on the host.

For example
-p 1111:1111