Skip to content

Could not find a valid Docker environment. And no attempted configurations? #6725

Closed Answered by mpiggott
mpiggott asked this question in Q&A
Discussion options

You must be logged in to vote

I eventually tracked this down.

Locally testcontainers is able to use one of the hardcoded docker strategies. However on Jenkins these strategies don't work and in my OSGi environment the Thread's context class loader is set to a PaxExam ClassLoader. This ClassLoader does not have access to the classes in TestContainers, so all of the dynamic strategies fail.

To solve this we do something like this:

GenericContainer gc = ....;
ClassLoader cl = Thread.getCurrentThread().getContextClassLoader();
try {
  Thread.getCurrentThread().setContextClassLoader(GenericContainer.class.getClassLoader());
  gc.start();
}
finally {
  Thread.getCurrentThread().setContextClassLoader(cl);
}

Not really clear…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mpiggott
Comment options

Comment options

You must be logged in to vote
1 reply
@mpiggott
Comment options

Answer selected by mpiggott
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants