Server-Client communication within Docker

I have a GUI application running on my host (a CentOS 7 VM) at 127.0.0.1:3281. This connects to a server, also running locally at 127.0.0.1:1341 via a TCP channel.

This works perfectly on my CentOS host. However, when I try to replicate the exact same setup inside a Docker container running the same version of CentOS - I am able to get the application and server started separately but there is no TCP channel established between them.

What would I have to change in my Docker version in order for this to work?

I have tried replicating the host network interface for the Docker container using the following flag in my docker run command, but that has not worked:

–network=host

I am really confused as to why it would not work within the container after having set it up the exact same way.

Should I attempt to expose ports and get the client from inside the container to connect to the server on the host?

Should I attempt to use the bridge network settings?

I don’t know if these would be of any help because the fix seems quite trivial, but I am completely unsure on how to proceed.

Please share your knowledge, anything could help!

EDIT: I noticed the same behavior when I ssh into my VM and try to start the application and server. They start on their own but there is no TCP channel established between the client and server.