Package reference page maintained from the source documentation in src/HealthChecks.ContainerRegistry.

Container Registry Health Check

This health check verifies an OCI or Docker Registry HTTP API v2 endpoint through the registry /v2/ endpoint.

By default, the check reports healthy when the registry endpoint returns a successful HTTP status code. It also reports healthy when a private registry returns 401 Unauthorized with a WWW-Authenticate challenge, because that response shows the registry endpoint is reachable and the authentication challenge is available.

Basic usage

services
    .AddHealthChecks()
    .AddContainerRegistry(new Uri("https://registry.example.com"));

Authenticated registry

Use ConfigureRequest or configure the named HTTP client when the health check should send credentials and require a successful response from the registry.

using System.Net.Http.Headers;
using HealthChecks.ContainerRegistry;

services
    .AddHealthChecks()
    .AddContainerRegistry(new Uri("https://registry.example.com"), options =>
    {
        options.AllowUnauthorizedResponse = false;
        options.ConfigureRequest = request =>
        {
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
        };
    });

Reverse proxy path

If the registry is exposed through a reverse proxy path, configure RegistryEndpointPath.

using HealthChecks.ContainerRegistry;

services
    .AddHealthChecks()
    .AddContainerRegistry(new Uri("https://proxy.example.com"), options =>
    {
        options.RegistryEndpointPath = "/registry/v2/";
    });

Authentication challenge policy

AllowUnauthorizedResponse defaults to true, so private registries can be checked without credentials. RequireAuthenticationChallenge defaults to true, so a 401 Unauthorized response is only healthy when it includes a WWW-Authenticate header.

services
    .AddHealthChecks()
    .AddContainerRegistry(new Uri("https://registry.example.com"), options =>
    {
        options.AllowUnauthorizedResponse = true;
        options.RequireAuthenticationChallenge = true;
    });

Parameters