From 286bcaa25977391bdb293fa7af700d3a3c6f2ac6 Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 3 Jun 2024 08:04:12 -0500 Subject: [PATCH 1/2] Add details about container runtime args. Fixes #707 --- docs/fundamentals/app-host-overview.md | 40 +++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 53b897793e..250acd577a 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -1,7 +1,7 @@ --- title: .NET Aspire orchestration overview description: Learn the fundamental concepts of .NET Aspire orchestration and explore the various APIs to express resource references. -ms.date: 05/23/2024 +ms.date: 06/03/2024 ms.topic: overview --- @@ -146,6 +146,44 @@ In the preceding example, the `apiservice` service has a named endpoint called ` .NET Aspire hosting packages and [.NET Aspire components](components-overview.md) are both delivered as NuGet packages, but they serve different purposes. While components provide client library configuration for consuming apps outside the scope of the app host, hosting packages provide APIs for expressing resources and dependencies within the app host. +### Express container resources + +To express a container resource, use the method: + +## [Docker](#tab/docker) + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +var ollama = builder.AddContainer("ollama", "ollama/ollama") + .WithBindMount("ollama", "/root/.ollama") + .WithBindMount("./ollamaconfig", "/usr/config") + .WithHttpEndpoint(port: 11434, targetPort: 11434, name: "ollama") + .WithEntrypoint("/usr/config/entrypoint.sh") + .WithContainerRunArgs("--gpus=all"); +``` + +For more information, see [GPU support in Docker Desktop](https://docs.docker.com/desktop/gpu/). + +## [Podman](#tab/podman) + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +var ollama = builder.AddContainer("ollama", "ollama/ollama") + .WithBindMount("ollama", "/root/.ollama") + .WithBindMount("./ollamaconfig", "/usr/config") + .WithHttpEndpoint(port: 11434, targetPort: 11434, name: "ollama") + .WithEntrypoint("/usr/config/entrypoint.sh") + .WithContainerRuntimeArgs("--device", "nvidia.com/gpu=all"); +``` + +For more information, see [GPU support in Podman](https://github.com/containers/podman/issues/19005). + +--- + +The preceding code adds a container resource named "ollama" with the image "ollama/ollama". The container resource is configured with multiple bind mounts, a named HTTP endpoint, an entrypoint that resolves to Unix shell script, and container run arguments with the . + Beyond the base resource types, , , and , .NET Aspire provides extension methods to add common resources to your app model. The following table lists the methods and their corresponding resource types: **Cloud-agnostic resources are available in the following NuGet packages:** From d39e31abfe9d1ea037de640a125eaa537ad39231 Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 3 Jun 2024 14:15:22 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/fundamentals/app-host-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 250acd577a..af277636fa 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -182,7 +182,7 @@ For more information, see [GPU support in Podman](https://github.com/containers/ --- -The preceding code adds a container resource named "ollama" with the image "ollama/ollama". The container resource is configured with multiple bind mounts, a named HTTP endpoint, an entrypoint that resolves to Unix shell script, and container run arguments with the . +The preceding code adds a container resource named "ollama" with the image "ollama/ollama". The container resource is configured with multiple bind mounts, a named HTTP endpoint, an entrypoint that resolves to Unix shell script, and container run arguments with the method. Beyond the base resource types, , , and , .NET Aspire provides extension methods to add common resources to your app model. The following table lists the methods and their corresponding resource types: