You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ImageFromDockerfile.withDockerfileFromBuilder not possible to use with proxy #5103
Please provide a way to allow customization of an image when pulling it through a proxy. For example this snippet does not work if ELASTICSEARCH_IMAGE uses an in-house/local docker proxy:
java.lang.IllegalStateException: Failed to verify that image 'localhost/testcontainers/shreetkrpuzjpwzg' is a compatible substitute for 'docker.elastic.co/elasticsearch/elasticsearch'. This generally means that you are trying to use an image that Testcontainers has not been designed to use. If this is deliberate, and if you are confident that the image is compatible, you should declare compatibility in code using the `asCompatibleSubstituteFor` method. For example:
DockerImageName myImage = DockerImageName.parse("localhost/testcontainers/shreetkrpuzjpwzg").asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch");
and then use `myImage` instead.
Is there a way to turn off this type of validation?
And note that 'localhost/testcontainers/shreetkrpuzjpwzg' is not a name from our code but that seems to be auto generated by something inside TestContainers. ELASTICSEARCH_IMAGE is in our case set to "in-house-proxy/elasticsearch/elasticsearch:6.8.8".
Great we could solve it for your use case 🙂
I will try to close and convert this issue into a GitHub Discussion question, let's see if this works as expected.
Also, we really appreciate advocating for Testconainers in your organization and helping others adopt it for their integration testing needs.
Activity
kiview commentedon Feb 21, 2022
Did you try the code as provided by the exception message?
This exception happens when you start the Elasticsearch container, it has nothing to do with pulling through a proxy.
nylund commentedon Feb 21, 2022
I did that for another case but I cannot wrestle the API to use DockerImageName instances in this case. The builder.from() method only takes a String.
nylund commentedon Feb 21, 2022
And note that 'localhost/testcontainers/shreetkrpuzjpwzg' is not a name from our code but that seems to be auto generated by something inside TestContainers. ELASTICSEARCH_IMAGE is in our case set to "in-house-proxy/elasticsearch/elasticsearch:6.8.8".
kiview commentedon Feb 21, 2022
Can you try something along the lines of:
nylund commentedon Feb 21, 2022
resolve()is protected so I can't call that one.bsideup commentedon Feb 21, 2022
.get() is the method
nylund commentedon Feb 21, 2022
Great, this works! Thanks so much for the fast feedback.
FYI - I am asking around internally if our company can become sponsors for Testcontainers. No promises but I'll see what I can do.
kiview commentedon Feb 21, 2022
Great we could solve it for your use case 🙂
I will try to close and convert this issue into a GitHub Discussion question, let's see if this works as expected.
Also, we really appreciate advocating for Testconainers in your organization and helping others adopt it for their integration testing needs.