Connect to port which is bind to 127.0.0.1

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

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

Because this port is bind to 127.0.0.1 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 ?

Set SERVER A to bind to 0.0.0.0:9000. As you note, definitionally, if SERVER A is bound only to 127.0.0.1, 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 127.0.0.1:9000:9000 --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 0.0.0.0. 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.)