Docker pull from container registry image fails due to Proxy Usage / docker bug
- 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
### Describe the bug
When using aspire to host locally the registry:3 image, I tried to push / pull images from the registry and the command times out, and the requests do not reach the registry itself (logs and traces show this).
Running the registry image directly without aspire works.
Also, if the registry is proxied using an executable then it also doesn't work.
### Expected Behavior
I should be able to push / pull images from the registry using docker cli from a registry hosted in aspire or any proxy executable I create for the registry.
### Steps To Reproduce
```csharp
builder.AddContainer(name, "registry", "3")
.WithHttpEndpoint(port: 5000, targetPort: 5000, name: "http")
.WithHttpHealthCheck("/v2/", endpointName: "http");
```
And then in terminal:
```sh
docker pull redis
docker tag redis localhost:5000/redis:latest
docker push ocalhost:5000/redis:latest
```
### Exceptions (if any)
Timeout on either connection or waiting for layer pull / push depending on the flavor of docker you are using (with or without containerd enabled)
### .NET Version info
.NET SDK:
Version: 9.0.304
Commit: f12f5f689e
Workload version: 9.0.300-manifests.6b700260
MSBuild version: 17.14.16+5d8159c5f
### Anything else?
After investigation with @davidfowl and @danegsta they found the root cause and workaround for now.
### Root Cause:
Docker VM doesn't bind aspire ports / random ports from the host correctly in certain situations.
Since the docker pull is happening in the Docker VM, the exposed post isn't available and the docker cli command timedout.
### Workaround:
Remove the proxy from your endpoints using:
```csharp
.WithHttpEndpoint(port: 5000, targetPort: 5000, isProxied: false, name: "http")
```
And only containers can be used to proxy requests from the docker cli.
Full registry resource after fix:
```csharp
builder.AddContainer(name, "registry", "3")
// isProxied must be false for host machine docker client to be able to push images to it
.WithHttpEndpoint(port: 5000, targetPort: 5000, name: "http", isProxied: false)
.WithHttpHealthCheck("/v2/", endpointName: "http")
.WithVolume("cortex-ai-registry", "/var/lib/registry")
.WithOtlpExporter();
```
Contributor guide
Assessment
This issue has not been assessed yet.