0

I'm setting up a custom TestContainer by pulling an image from a private registry. At the moment it looks like this (it works):

   public static GenericContainer<?> customContainer = new GenericContainer<>(
      DockerImageName.parse("private-registry.net:port/path/custom-image"))
      .withCreateContainerCmdModifier(cmd -> cmd.withName("Test_Custom").withHostName("custom"))

I'm setting the login information through System.setProperty("registry.username", "username") (same for password). I don't want my login to be plaintext code. The idea is to login through settings.xml where the private repositories are defined. I'm completely new to this so I don't know if that's even possible? I've tried just adding it into the xml file like so:

<repositories>
   <id>custom-image</id>
   <url>private-registry.net:port/path/custom-image</url>
   ......
</repositories>
<servers>
       <server>
            <id>custom-image</id>
            <username>username</username>
            <password>password</password>
        </server>
</servers>

It doesn't seem to "detect" automatically, how do I get the container to refer to its url and credentials within the xml? Or is this not possible? I only see answers on how you push an image through maven.

Pompompurin
  • 165
  • 3
  • 14
  • 1
    The access to a docker registry is not controlled by using something from settings.xml. This is part of Docker which means you need to configure the access via daemon.json and do also a docker login upfront. – khmarbaise Aug 08 '22 at 12:21
  • @khmarbaise I'm logging in via setting the registry.name and registry.password, is that a daemon.json setting? – Pompompurin Aug 08 '22 at 12:27
  • 1
    These look like your Maven registry settings to me. Testcontainers takes it from usual Docker credential locations (there are many available). After you do a `docker login`, it should work in your environment. – Kevin Wittek Aug 08 '22 at 17:16

0 Answers0