Open OmarHawk opened 2 weeks ago
Hi, I think the code should be
elasticsearchContainer = new ElasticsearchContainer(
DockerImageName.parse("myregistry.azurecr.io/docker.io/library/elasticsearch")
.asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch")
.withTag("8.10.4")
)
We do have the host name written into
testcontainers.properties file in our classpath via hub.image.name.prefix
property as explained in https://java.testcontainers.org/features/image_name_substitution/
hub.image.name.prefix=myregistry.azurecr.io/docker.io/
That's why we don't mention it explicitly in our Java code.
Hi, I think the code should be
elasticsearchContainer = new ElasticsearchContainer( DockerImageName.parse("myregistry.azurecr.io/docker.io/library/elasticsearch") .asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch") .withTag("8.10.4") )
Indeed, that did work - explicitly maintaining the registry name as part of the DockerImageName.parse
call. I really do wonder why there is a difference between usage of
hub.image.name.prefix
and explicitly maintaining it in the Java code. In my opinion they are supposed to be treated equally.
Module
Elasticsearch
Testcontainers version
1.19.8
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host Arch
amd64
Docker version
What happened?
We are currently trying to use Azure Container registry (ACR) to serve as a pull through cache for Docker images. That one has quite some limitations (e.g.: https://github.com/Azure/acr/issues/599#issuecomment-1751689962), forcing us to configure the Elasticsearch Testcontainer like this (please note the
library/
prefix):This one fails, as it claims it tries to use the OSS version of Elasticsearch while activating a password, even though it is not true (it is not the OSS image...) + I override this anyway with
asCompatibleSubstituteFor
Relevant log output
Additional Information
Seems like the detection for
isOss
is could be improved - or maybe removed as it seems marked deprecated anyway...https://github.com/testcontainers/testcontainers-java/blob/b4b1c2022d540177ada794b028c99fba5daeba1f/modules/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java#L108-L117