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

The networking overview docs could use a section on best practices for containers with a persistent lifetime #2481

Open
danegsta opened this issue Jan 23, 2025 · 0 comments

Comments

@danegsta
Copy link
Member

danegsta commented Jan 23, 2025

Type of issue

Missing information

Description

We've run into some user confusion with regards to networking behavior with persistent containers. There's an existing section on configuring networking for container ports, but we'd like to be able to point people to best practices when a container is configured with a persistent lifetime (it will persist between App Host runs). At a basic level, something like this for guidance:

When a container is configured with a persistent lifetime, we recommend configuring the resource endpoints with a fixed unproxied host port. This will ensure that your persistent container endpoints can be accessed whether or not your App Host project is running. For example:

var builder = DistributedApplication.CreateBuilder(args);

var ollama = builder.AddContainer("ollama", "ollama/ollama")
    .WithLifetime(ContainerLifetime.Persistent)
    .WithEndpoint(port: 11400, targetPort: 11434);

This will expose a TCP port 11400 on the host bound to port 11434 in the ollama container resource. Because ollama has a persistent lifetime, the container will continue running between starts and stops of the App Host project and will still be reachable via port 11400.

Page URL

https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/networking-overview#container-ports

Content source URL

https://github.com/dotnet/docs-aspire/blob/main/docs/fundamentals/networking-overview.md

Document Version Independent Id

28b9fa36-8d97-7637-cee2-3971d24c2333

Article author

@IEvangelist

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant