Pulling an image (with namespace) from a private container registry does not work
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:6

Top Related StackOverflow Question
Yes you’re right.
DockerImagedoes not parsemyregistry.azurecr.io/namespacepart1/namespacepart2/imagename:latestcorrect. 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
IDockerImageargument a little bit different, try:instead.
@HofmeisterAn , I have tested this with
1.5.0-beta20201010.3and the issue is indeed fixed. Thanks.