Docker Community Forums

Share and learn in the Docker community.

Connect to port which is bind to


(Jeanluca) #1

In have these two containers SERVER A and SERVER B. Now SERVER A runs a tool which creates a port on

I’m trying to connect from SERVER B to SERVER A on port 9000

Because this port is bind to it is as far as I know only accessible from localhost (from inside SERVER A). So the question is, is there some docker command/option or something else, facilitating this? How can I establish this connection ?

(David Maze) #2

Set SERVER A to bind to As you note, definitionally, if SERVER A is bound only to, nothing outside of SERVER A (and, in Docker land, nothing outside the container running it) can reach it. Docker doesn’t really change or affect this at all, other than making it less likely that SERVER A and SERVER B will be “running on the same system”.

(If you docker run -p --name server-a server-a and docker run --link server-a:server-a server-b, then the service still won’t be visible outside of the physical host, but SERVER B will see a host name server-a that it can connect to. This does rely on SERVER A binding to There’s also a newer way to do this with Docker networks and without --link, I think even a preferred way, that I’ve never personally set up.)