# ContainerRegistryResource Constructors

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [ContainerRegistryResource](/reference/api/csharp/aspire.hosting/containerregistryresource.md)
- Kind: `Constructors`
- Members: `1`

Represents a general-purpose container registry resource that can be used to reference external container registries (e.g., Docker Hub, GitHub Container Registry, or private registries) in the application model.

## ContainerRegistryResource(string, ReferenceExpression, ReferenceExpression?)

- Name: `Constructor(string, ReferenceExpression, ReferenceExpression?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ContainerRegistryResource.cs#L50-L57)

Initializes a new instance of the [ContainerRegistryResource](/reference/api/csharp/aspire.hosting/containerregistryresource.md) class.

```csharp
public class ContainerRegistryResource
{
    public ContainerRegistryResource(
        string name,
        ReferenceExpression endpoint,
        ReferenceExpression? repository = null)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource.
- `endpoint` ([ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md))
  The endpoint URL or hostname of the container registry.
- `repository` ([ReferenceExpression?](/reference/api/csharp/aspire.hosting/referenceexpression.md)) `optional`
  The optional repository path within the container registry.

## Exceptions

- `ArgumentNullException` -- Thrown when `endpoint` is `null`.
