Compiler Warning ASPIRECONTAINERRUNTIME001
Container runtime types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.
This diagnostic warning is reported when using the experimental IContainerRuntime interface and related container runtime implementations. These APIs provide abstraction over container runtimes like Docker and Podman for building, tagging, pushing, and managing container images during deployment.
The IContainerRuntime interface provides a unified abstraction for interacting with container runtimes:
- Runtime detection: Check if Docker or Podman is running and available
- Image building: Build container images from Dockerfiles with build arguments and secrets
- Image management: Tag, push, and remove container images
- Registry operations: Login to container registries for authentication
This API is experimental because the container runtime abstraction layer is being refined based on deployment scenario requirements, and the interface may evolve to support additional container runtime features or optimizations.
Example
Section titled “Example”The following code generates ASPIRECONTAINERRUNTIME001:
var builder = DistributedApplication.CreateBuilder(args);
// Using IContainerRuntimevar containerRuntime = builder.Services.BuildServiceProvider().GetRequiredService<IContainerRuntime>();var isRunning = await containerRuntime.CheckIfRunningAsync(cancellationToken);var runtimeName = containerRuntime.Name;Related types
Section titled “Related types”IContainerRuntime: Interface representing a container runtime (Docker, Podman)DockerContainerRuntime: Implementation for Docker runtimePodmanContainerRuntime: Implementation for Podman runtimeCheckIfRunningAsync(): Verifies if the container runtime is availableBuildImageAsync(): Builds a container image from a DockerfileTagImageAsync(): Tags a container image with a new namePushImageAsync(): Pushes a container image to a registryRemoveImageAsync(): Removes a container imageLoginToRegistryAsync(): Authenticates with a container registry
To correct this warning
Section titled “To correct this warning”Suppress the warning with either of the following methods:
-
Set the severity of the rule in the .editorconfig file.
.editorconfig [*.{cs,vb}]dotnet_diagnostic.ASPIRECONTAINERRUNTIME001.severity = noneFor more information about editor config files, see Configuration files for code analysis rules.
-
Add the following
PropertyGroupto your project file:C# project file <PropertyGroup><NoWarn>$(NoWarn);ASPIRECONTAINERRUNTIME001</NoWarn></PropertyGroup> -
Suppress in code with the
#pragma warning disable ASPIRECONTAINERRUNTIME001directive:C# — Suppressing the warning #pragma warning disable ASPIRECONTAINERRUNTIME001var containerRuntime = builder.Services.BuildServiceProvider().GetRequiredService<IContainerRuntime>();var isRunning = await containerRuntime.CheckIfRunningAsync(cancellationToken);#pragma warning restore ASPIRECONTAINERRUNTIME001