title: Can a java TestContainer be started without attempting to call the default registry?
body: <p>At work, we have decided we would like to use the java <a href="https://www.testcontainers.org/" rel="nofollow noreferrer">TestContainers</a> package, and it has fallen to me to learn and implement this package. It is important to note that security is a top priority at work, so we are behind a proxy and run our own registry to contain our docker images.</p>
  <p>This is what I've got so far.</p>
  <pre><code>var dockerImage = DockerImageName.parse(&quot;&lt;secure-registry&gt;/mongo:latest&quot;)
                  .asCompatibleSubstituteFor(&quot;mongo&quot;);
          MongoDBContainer mongoDBContainer = new MongoDBContainer(dockerImage)
                  .withImagePullPolicy(PullPolicy.defaultPolicy())
                  .withExposedPorts(27019);
          mongoDBContainer.start();
  </code></pre>
  <p>Not alot, but that's because I can't progress any further. Any time I attempt to run this code, it gets as far as .start() before throwing the following error</p>
  <pre><code>com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {&quot;message&quot;:&quot;Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.65.1:53: no such host&quot;}
  </code></pre>
  <p>The issue is obviously that our proxy is blocking the default registry. I could probably fiddle with proxy settings on my machine so the registry can be resolved, but that is not a company wide solution. This app will be developed and run on many different machines and environments, and reconfiguring all of them would be more effort than it's worth. Furthermore, <em>it shouldn't be communicating with the default registry at all.</em> We have our own registry for a reason. The only real solution I see here is to remove this call entirely but so far, the documentation for both <a href="https://javadoc.io/static/org.testcontainers/testcontainers/1.15.2/org/testcontainers/utility/DockerImageName.html" rel="nofollow noreferrer">DockerImageName</a> and the <a href="https://javadoc.io/static/org.testcontainers/testcontainers/1.15.2/org/testcontainers/containers/Container.html" rel="nofollow noreferrer">containers</a> have been of no help.</p>
  <p>If anyone has attempted this, or has another solution, it would be very helpful.</p>