Skip to content

"Could not find a valid Docker environment" error while running tests from Jenkins on the Ubuntu #613

@endless-qa

Description

@endless-qa

The environment:

  • Host machine: Ubuntu 16.04 with Docker installed and running;
  • Jenkins which is run via Docker container on the same host machine.

I am using testcontainers-java in my project and trying to setup executing SeleniumWebdriver tests via Maven from the Jenkins CI. Example code is taken from the official documentation and works perfectly if I run tests from IDE installed on the same Linux host machine, or if I run tests from a terminal via Maven - testcontainers-java starts an appropriate container and I receive correct data from the browser under test.

However, when I try to run the same tests with the same set of Maven commands from a Jenkins job - I receive the following error:

java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$2(DockerClientProviderStrategy.java:146) at java.util.Optional.orElseThrow(Optional.java:290) at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:138) at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:99) at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:126) at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:166) at org.testcontainers.containers.BrowserWebDriverContainer.<init>(BrowserWebDriverContainer.java:61)

I suspect that there is maybe some issue because Jenkins itself is running inside another container and cannot get access to the installed Docker instance from inside. Is there any way to solve this issue? I was trying to search for a solution a lot but didn't succeed. This forum is my last hope

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions