I have an Aspire project that runs RabbitMQ, MongoDB, and PostgreSQL in Docker containers. My AppHost project defines them like this:
var rabbitMQ = builder.AddRabbitMQ("rabbitmq")
.WithDockerfile("RabbitMQ")
.WithHttpEndpoint(15672, 15672, "http-15672")
.WithHttpEndpoint(5672, 5672, "http-5672")
.WithExternalHttpEndpoints();
var mongoDb = builder.AddMongoDB("mongodb")
.WithHttpEndpoint(27017, 27017, "http-27017")
.WithExternalHttpEndpoints();
var postgres = builder.AddPostgres("postgres")
.WithImage("timescale/timescaledb", "latest-pg16")
.WithHostPort(5432)
.WithExternalHttpEndpoints();
When I run the AppHost on my Windows machine, I immediately get errors like:
failed to start Container {...failed to listen on TCP socket: address already in use...}
This happens both for my RabbitMQ and MongoDB containers, while my PostgreSQL starts correctly.
Software Versions:
I have verified:
On a fresh Windows install with all software installed from scratch, the same issue occurs. But, it works on Windows/MacOS machines from my teammates.
Does anyone has any idea where to look from here ? Could it be a candidate to open official issue on GitHub ?
Thanks in advance.
I've managed to figure it out! Here is the explanation for those wondering..
For some reason, registering host ports using ".WithHttpEndpoint" produce this error in latest versions of Docker Desktop. But, if you revert Docker Desktop to several older minor versions, it solves it. (Anything before 4.40. it seems)
On the other hand, it seems that there is indeed a fix also on latest version of Docker Desktop, you have to pass host ports like this:
var mongoDb = builder.AddMongoDB("mongodb", 27017)
.WithExternalHttpEndpoints();