Docker Compose Networking

I’m currently deploying a docker-compose stack of a React Frontend, .NET Core 3.0 API and a Postgres Database on servers that I manage. I’m doing the deployment using GitLab-CI through a self-hosted GitLab instance. I’m struggling to understand how to properly reference each container over the bridge network that I established at creation. For instance, I’m wanting to simply reference the API from the front end through {container-name}:port/API instead of having to use a domain name reference such as

I’m open to suggestions and sharing my repository if it helps.

Thank you,

Tyler Williams


Sorry for responding more than a month later :sweat_smile:, but maybe you still have the problem and/or it may help someone else.

Unless I misunderstand something, what you’re trying is not possible.

If the front end we’re talking about is a web app (on the browser, angular, react, vue, etc.), this app has to be downloaded to the client computer. This means that the container-name is not available anymore, because you’re now working on a remote computer, hence you need some way to communicate with it (domain name or IP). Basically, only while your containers are on the same network, they can be referenced by the instance name.

An alternative would be to have a micro service in front of the API, and expose that to the internet using a domain name, but I think that would be extra work.

I hope I understood the question right and this helps :slight_smile:,


1 Like

Yeah, as skaparate explained, if all your containers are on the same machine you do not need to setup network.

Just reference them like this: {service-name}/API

  • To synchronize them in order use depend on in your docker-compose yaml.
  • use restart always if depend on is not enough