Reputation: 1627
These are my codes in AppHost
var postgres = builder
.AddPostgres("Postgres", port: 5432)
.WithImageTag("latest")
.WithContainerName("MyDatabase-PostgresDb-Aspire")
.WithEnvironment("POSTGRES_USER", "postgres")
.WithEnvironment("POSTGRES_PASSWORD", "postgrespassword")
.WithEnvironment("POSTGRES_DB", "MyDatabase")
.WithEnvironment("POSTGRES_HOST_AUTH_METHOD", "trust")
.WithDataBindMount(source: "F:\\DockerVolumes\\Postgres\\Data", isReadOnly: false)
.WithLifetime(ContainerLifetime.Persistent)
.AddDatabase("MyDatabase");
var web = builder.AddProject<ArshidWeb>(nameof(ArshidWeb))
.WithExternalHttpEndpoints()
.WithScalar().WithSwagger().WithOpenApi()
.WaitFor(postgres)
.WithReference(postgres)
;
And This is my ConnectionString
"ConnectionStrings": {
"PostgresConnection":"Host=Postgres;Port=5432;Database=MyDatabase;Username=postgres;Password=postgrespassword;"
}
It works with docker-compose.yml and dockerfile well
But with Aspire seems service discovery won't find Postgres server and throws this error :
System.Net.Sockets.SocketException: 'No such host is known.'
Where did I had mistake ?
Upvotes: 0
Views: 15