question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Potential issues when pulling Elasticsearch image

See original GitHub issue

Hi everyone, Could you help me here? My code can not load the testcontainer properties under the src/test/rescourse in CI docker maven enviroment.

But I can run it in local by Windows: C:/Users/myuser/.testcontainers.properties.

As we know, we can config our parameters follow below three ways.

  1. Environment variables
  2. .testcontainers.properties in user’s home folder. Example locations: Linux: /home/myuser/.testcontainers.properties Windows: C:/Users/myuser/.testcontainers.properties macOS: /Users/myuser/.testcontainers.properties
  3. testcontainers.properties on the classpath.

Because the CI machine, so I config it on the classpath (src/test/resources/*) image

`public class ElasticInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { @ClassRule public static ElasticsearchContainer container = new ElasticsearchContainer();

/**
 * @param applicationContext
 */
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
	container.start();
	TestPropertyValues.of("elasticsearch.host=" + container.getHost(),
					"elasticsearch.port=" + container.getMappedPort(9200))
			.applyTo(applicationContext);
}

}

@Testcontainers @SpringBootTest @ActiveProfiles(profiles = {“test”}) @ContextConfiguration(initializers = {ElasticInitializer.class}) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class PMBServiceImplTest { }`

16:48:42 08:48:42.863 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@49872d67 testClass = PMWHServiceImplTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@56303b57 testClass = PMWHServiceImplTest, locations = '{}', classes = '{class com....MetaApplication}', contextInitializerClasses = '[class .....impl.ElasticInitializer]', activeProfiles = '{test}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@338fc1d8, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@55cb6996, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@dc7df28, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@60f00693, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@7eecb5b8, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@448ff1a8], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null]. 16:48:42 08:48:42.925 [main] DEBUG org.testcontainers.utility.TestcontainersConfiguration - Testcontainers configuration overrides will be loaded from file:/root/.testcontainers.properties 16:48:42 08:48:42.940 [main] WARN org.testcontainers.utility.TestcontainersConfiguration - Attempted to read Testcontainers configuration file at file:/root/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: /root/.testcontainers.properties (No such file or directory) 16:48:42 08:48:42.944 [main] INFO org.testcontainers.utility.ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor') 16:48:43 08:48:42.952 [main] DEBUG org.testcontainers.utility.PrefixingImageNameSubstitutor - No prefix is configured 16:48:43 08:48:42.952 [main] DEBUG org.testcontainers.utility.ImageNameSubstitutor - Did not find a substitute image for docker.elastic.co/elasticsearch/elasticsearch:7.9.2 (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')) 16:48:43 08:48:42.969 [main] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - $XDG_RUNTIME_DIR is not set. 16:48:43 08:48:42.969 [main] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - '/root/.docker/run' does not exist. 16:48:43 08:48:42.999 [main] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - '/run/user/0' does not exist. 16:48:43 08:48:42.999 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Trying out strategy: UnixSocketClientProviderStrategy 16:48:43 08:48:43.001 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock) 16:48:43 08:48:43.003 [main] INFO org.testcontainers.dockerclient.DockerMachineClientProviderStrategy - docker-machine executable was not found on PATH ([/opt/java/openjdk/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /opt/apache-maven/bin]) 16:48:43 08:48:43.003 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were: 16:48:43 08:48:43.003 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock) 16:48:43 08:48:43.004 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - As no valid configuration was found, execution cannot continue 16:48:43 08:48:43.004 [main] DEBUG org.testcontainers.utility.PrefixingImageNameSubstitutor - No prefix is configured 16:48:43 08:48:43.004 [main] DEBUG org.testcontainers.utility.ImageNameSubstitutor - Did not find a substitute image for docker.elastic.co/elasticsearch/elasticsearch:7.9.2 (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')) 16:48:43 08:48:43.007 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@4b45dcb8] to prepare test instance [.......dao.impl.PMWHServiceImplTest@3d08f3f5] 16:48:43 java.lang.IllegalStateException: Failed to load ApplicationContext

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
eddumelendezcommented, May 16, 2022

For the second case you should use something like this

private static DockerImageName IMAGE = DockerImageName.parse("internal.repo.com.com/elasticsearch:latest")
            .asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch");

as mentioned by the exception message you just shared

0reactions
eddumelendezcommented, Nov 1, 2022

Closing this because of lack of activity. @swift0303 feel free to reopen it with more info or join slack channel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install Elasticsearch with Docker - Elastic
Pull the Elasticsearch Docker imageedit ... Obtaining Elasticsearch for Docker is as simple as issuing a docker pull command against the Elastic Docker...
Read more >
Pulling Elasticsearch Docker images for previous versions
The command mentioned in the site is docker pull elasticsearch which pulls the docker image with latest tag. Since you want specific version...
Read more >
bitnami/elasticsearch-exporter - Docker Image
We'd love for you to contribute to this container. You can request new features by creating an issue or submitting a pull request...
Read more >
How to Run Elasticsearch 8 on Docker for Local Development
Start Elasticsearch and Kibana with Docker and Docker Compose in minutes. Image by 512893 on Pixabay. For the new major version of Elasticsearch...
Read more >
elasticsearch 8.5.1 - Artifact Hub
This Helm chart is a lightweight way to configure and run our official Elasticsearch Docker image. Warning When it comes to running the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found