microsoft / microsoft/aspire

Support private container registry for all pulled images

Open
#18,015 5 comments 0 reactions 0 assignees View on GitHub
area-orchestrator triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I am working in an environment where I can't pull images from arbitrary image registries. This is the same issue as reported in https://github.com/microsoft/aspire/issues/1438 which was closed, I think incorrectly.

For the containers added in my AppHosts, I have this workaround to set the registry if it is not set:
```csharp
// set the image registry to be our artifactory mirrors if not explicitly set
builder.OnBeforeStart(static (e, _) =>
{
foreach (var container in e.Model.GetContainerResources())
{
if (container.TryGetLastAnnotation(out var annotation))
{
annotation.Registry ??= ImageBase;
}
}
return Task.CompletedTask;
});
```
Which works, but seems like it could be a built in feature, unless I have missed it.

The additional problem is for some things, like the new container tunnel, it does not seem like there is a way to customize this image, so I get the error:

```
Aspire.Hosting.DistributedApplicationException: One or more container network tunnel proxies did not start successfully: 'aspire-container-network-tunnelproxy': Container image for container network tunnel could not be built, or its presence could not be verified: failed to check if client proxy image needs to be built: failed to check if the client proxy image exists: failed to pull client proxy base image mcr.microsoft.com/azurelinux/base/core:3.0 and no local copy was available: docker command 'PullImage' returned with non-zero exit code 1
error
Error response from daemon: failed to resolve reference "mcr.microsoft.com/azurelinux/base/core:3.0": failed to do request: Head "https://mcr.microsoft.com/v2/azurelinux/base/core/manifests/3.0": EOF
docker command 'InspectImages' returned with non-zero exit code 1
object not found
image not found
Error response from daemon: No such image: mcr.microsoft.com/azurelinux/base/core:3.0
at Aspire.Hosting.Dcp.ContainerCreator.WaitForTunnelProxyAsync(ContainerNetworkTunnelProxy tunnelProxy, IDcpObjectFactory factory, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/ContainerCreator.cs:line 607
at Aspire.Hosting.Dcp.ContainerCreator.CreateTunnelProxyResourceAsync(IDcpObjectFactory factory, List`1 tunnels, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/ContainerCreator.cs:line 468
at Aspire.Hosting.Dcp.ContainerCreator.EnsureHostConnectivityAsync(ImmutableArray`1 hostDependencies, ContainerCreationContext cctx, IDcpObjectFactory factory, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/ContainerCreator.cs:line 531
at Aspire.Hosting.Dcp.ContainerCreator.CreateHostDependentContainerAsync(RenderedModelResource`1 cr, ImmutableArray`1 hostDependencies, ContainerCreationContext cctx, IDcpObjectFactory factory, CancellationToken cToken) in /_/src/Aspire.Hosting/Dcp/ContainerCreator.cs:line 643
at Aspire.Hosting.Dcp.ContainerCreator.CreateObjectAsync(RenderedModelResource`1 cr, ContainerCreationContext cctx, ILogger logger, IDcpObjectFactory factory, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/ContainerCreator.cs:line 263
at Aspire.Hosting.Dcp.DcpExecutor.<>c__DisplayClass50_1`2.<g__CreateReplicaAsync|1>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 905
```

### Describe the solution you'd like

I would like to be able to set a global container registry default, similar to the [per-resource one](https://aspire.dev/integrations/compute/docker/#configure-a-container-registry) so that all images will be pulled from a given mirror.

For example if I have `artifactory.somecompany.com/docker-mirror/` I would be able to express this as
```charp
builder.AddDefaultContainerRegistry("artifactory.somecompany.com/docker-mirror/");
```
and have all images use this as the base

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.