I was working on https://github.com/Azure/azure-sdk-for-java/pull/40388 when I noticed the following, azurite full image is mcr.microsoft.com/azure-storage/azurite:latest, however I should register azure-storage/azurite as connection name, see the implementation in order to make it work.

Looking at the code, I found that the connection name only considers the repository from the full image (as you can see in the link below), ignoring the registry. Meanwhile implementing Service Connections I thought the connection name is always the image name, which in most cases only considers the repository. When I was working on the PR mentioned at the beginning I used the full image (registry + repository) as connection name and it was not working.

https://github.com/spring-projects/spring-boot/blob/1a2919bb0e58592b0ff16dae22909e2e2237312b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ContainerConnectionSource.java#L88

If this is not expected then in order to fix it, should be replaced by imageName.asCanonicalNameString().

Comment From: wilkinsona

I don't think we should consider the name of the registry. It would complicate things when someone's using a mirror where the repository portion of the name is unchanged as it would make it less likely that things would match without using the name attribute of @ServiceConnection.

The documentation currently states that:

by default Container.getDockerImageName() is used to obtain the name used to find connection details.

This is ambiguous as we don't describe how the Docker image name is used. We should improve that to describe that it's only the repository that's used, i.e. neither the registry nor the version is considered.