question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pulling an image (with namespace) from a private container registry does not work

See original GitHub issue

Describe the bug Not sure if it is a bug, I might be doing something wrong. I want to pull an image from a private container registry, and to do that, I use the following code:

var myContainer = new TestcontainersBuilder<TestcontainersContainer>()
                                    
              .WithImage("myregistry.azurecr.io/namespacepart1/namespacepart2/imagename:latest")
              .WithRegistryAuthentication("https://myregistry.azurecr.io", "username", "p4ssw0rd")
              .WithName("processor-end2endtests")
              .Build();

await myContainer.StartAsync();

When starting the container, I get an error which says:

'Docker API responded with status code=InternalServerError, response={“message”:“Get https://registry-1.docker.io/v2/namespacepart2/imagename/manifests/latest: unauthorized: incorrect username or password”}

I’ve double checked the username & password, but everything should be ok. I do wonder if the protocol that I specify for the registryEndpoint parameter in WithRegistryAuthentication is correct. (If I do notspecify a protocol, an exception is thrown saying that the endpoint does not represent a valid Uri).

Since the WithRegistryAuthentication method is marked as obsolete, I’ve also tried to first make sure that I’m authenticated with the Azure Container Registry in question by executing an az acr login command, but this doesn’t help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
HofmeisterAncommented, Oct 8, 2020

What I do notice, is that I want to pull the image namespacepart1/namespacepart2/imagename but the exception message mentions an url which says https://registry-1.docker.io/v2/namespacepart2/imagename/manifests/latest so in fact, the first part of the namespace is missing.

Yes you’re right. DockerImage does not parse myregistry.azurecr.io/namespacepart1/namespacepart2/imagename:latest correct. I didn’t know that Docker supports nested «namespaces» / «names».

Basically we need to fix: https://github.com/HofmeisterAn/dotnet-testcontainers/blob/3fc46c73795eeb997afc6337e2180fdbb40fcf3a/src/DotNet.Testcontainers/Images/DockerImage.cs#L18

and add a proper parser that maps the properties correct and set FullName.


In the meantime you could try to create your IDockerImage argument a little bit different, try:

.WithImage(new DockerImage("myregistry.azurecr.io", "namespacepart1/namespacepart2/imagename", "latest"))

instead.

0reactions
fgheyselscommented, Oct 10, 2020

@HofmeisterAn , I have tested this with 1.5.0-beta20201010.3 and the issue is indeed fixed. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kubernetes cannot pull an image from private repository on ...
1 Answer 1 ... OK, the problem lies in namespaces: all my deployments, pods, services, etc. live inside a separate namespace BUT command...
Read more >
Pull an Image from a Private Registry
This page shows how to create a Pod that uses a Secret to pull an image from a private container image registry or...
Read more >
Kubernetes pull image error in non-default namespace
I have a manifest that works fine in a default namespace. The image is cached on my laptop docker registry and I have...
Read more >
Troubleshooting image pull secrets that use API keys
Your cluster uses an API key that is stored in an image pull secret to authorize the cluster to pull images from IBM...
Read more >
Pulling Docker image from GitLab Container Registry ...
I have some base Docker images hosted in a private repository's container registry in GitLab. I reference this image from other projects in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found