I was testing a project converter to container locally and I realized that it doesn't work because we pass the localhost address instead of using the host address (host.docker.internal). Localhost is local to this container so this always blows up.
using Aspire.Hosting.Otlp;
using Aspire.Hosting.Redis;
var builder = DistributedApplication.CreateBuilder(args);
var pubsub = builder.AddRedisContainer("pubsub");
// Projects
//builder.AddProject<RedisPubSub.App.Projects.Publisher>()
// .WithRedis(pubsub);
//builder.AddProject<RedisPubSub.App.Projects.Subscriber>()
// .WithRedis(pubsub);
// Project published as containers
builder.AddContainer("publisher", "publisher")
.WithRedis(pubsub)
.WithOtlpExporter();
builder.AddContainer("subscriber", "subscriber")
.WithRedis(pubsub)
.WithOtlpExporter();
builder.Build().Run();
The easiest fix here would be to always use host.docker.internal instead of localhost for anything that runs in a container. Injecting different environment based on the consumer might be a bit more difficult...
cc @karolz-ms
I was testing a project converter to container locally and I realized that it doesn't work because we pass the localhost address instead of using the host address (host.docker.internal). Localhost is local to this container so this always blows up.
The easiest fix here would be to always use
host.docker.internalinstead of localhost for anything that runs in a container. Injecting different environment based on the consumer might be a bit more difficult...cc @karolz-ms