Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With* methods don't work with containers #128

Closed
davidfowl opened this issue Oct 8, 2023 · 10 comments
Closed

With* methods don't work with containers #128

davidfowl opened this issue Oct 8, 2023 · 10 comments
Assignees
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator

Comments

@davidfowl
Copy link
Member

davidfowl commented Oct 8, 2023

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

@davidfowl davidfowl added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Oct 9, 2023
@davidfowl davidfowl added this to the some time after preview milestone Oct 9, 2023
@danmoseley danmoseley removed this from the needs milestone (for GA) milestone Nov 13, 2023
@davidfowl davidfowl added this to the preview 2 (Dec) milestone Nov 24, 2023
@mitchdenny
Copy link
Member

This is going to be a pain. It appears that host.docker.internal is not enabled by default on Linux hosts. So we would need to add platform specific logic here.

@mitchdenny
Copy link
Member

related: moby/moby#40007

@mitchdenny
Copy link
Member

@karolz-ms for DCP on Linux we might need to invoke with --add-host=host.docker.internal:host-gateway when spinning up a container with Docker.

@danmoseley
Copy link
Member

@adityamandaleeka is @BrennanConroy planning to pick up app model work? David suggests this might be a good one to start with. Preview 2 cc is Tues 12/5

@danmoseley
Copy link
Member

We believe DCP work is done.

@karolz-ms
Copy link
Member

I do not think so/don't recall us adding this option on DCP side

@davidfowl
Copy link
Member Author

This wasn't the one @danmoseley , it was the command line args for containers 😄

@danmoseley
Copy link
Member

argh -- thanks for the correction. don't mind me, just dropping in and causing chaos in the issues

@davidfowl
Copy link
Member Author

Mitigation in place #1203

@davidfowl
Copy link
Member Author

This may end up being the long-term solution since we're going through proxies here. I'm going to close this as resolved for now and we can track another networking support in containers here

@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator
Projects
None yet
Development

No branches or pull requests

5 participants