-
I am trying to add an Unleash instance to my application, which involves setting up 2 containers: one running postgres, and one running Unleash. Unleash then needs to be configured to point to the postgres database. In the Unleash documentation, its suggested to add both containers to a docker network. When setting this up in Aspire, my postgres resource's host points to 127.0.0.1, which is not accessible from within the unleash container, and so unleash fails to connect to the database. If I use the How can I configure my application to allow one container resource to connect to another container resource? I have a simple reproduction here: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
For container to container communication use resource name as host and container port for port. If the resource name is This is an example that Redis Insight configured to connect to redis by container to container communication: |
Beta Was this translation helpful? Give feedback.
-
Thanks so much for the example! I updated my reproduction with the working code, specifically:
|
Beta Was this translation helpful? Give feedback.
For container to container communication use resource name as host and container port for port. If the resource name is
postgres
then the unleash container can connect to postgres container bypostgres:5432
host and port.This is an example that Redis Insight configured to connect to redis by container to container communication:
https://github.com/dotnet/aspire/blob/main/src%2FAspire.Hosting.Redis%2FRedisBuilderExtensions.cs#L242-L248