testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
7.9k stars 1.62k forks source link

DockerClientConfigUtils#getDefaultGateway() is failing with syslog driver #879

Open romainverduci opened 5 years ago

romainverduci commented 5 years ago

Hello guys,

I'm trying to use testcontainers-java (which I like a lot) and I can't make it work in my CI infrastructure. The reason of the failure is because I'm running my tests inside docker and the docker logging driver is configured to syslog.

For what I understood, this code is trying to read the log to get the output of a command to get the gateway ip and it's failing because getting the log is not supported by syslog. Therefore the gateway ip address can not be determined and the library can not properly manage containers.

I'm getting the following error in the logs of my build:

10:11:34.252 [tc-okhttp-stream-247575268] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"configured logging reader does not support reading"}

It looks like an issue to me as the library can not be used with such configuration. I'd like to have your thoughts on that and eventually know if there could be any workaround I could use.

Thank in advance !

kiview commented 5 years ago

Oh yes you are right, this will fail with all log drivers except the default json driver and journal driver. This is however a bug (or missing feature) of the docker-java library, which we use as a client.

Would you like to raise this issue over there as well?

Regarding Testcontainers, I think it's an unusual case to have your containers in CI running with a different log driver, but still it would be nice to support it.

romainverduci commented 5 years ago

@kiview Thanks for your quick reply ! I opened the bug here because I thought there could be another way to get the ip without having to access the logs of a container. I think the logs command is not even supported by docker itself with the syslog driver so I don't know if raising the issue to docker-java would help, I will check that anyway.

To help me moving forward, do you know if it's possible to override the gateway ip using an environment variable or java option, I tried to look for that without success reading the code / doc of the project.

kiview commented 5 years ago

Maybe we could have other implementation variants, using docker inspect like commands and checking the gateway there? The problem is, that we have probably more spots in our code where we use Docker logs.

Regarding the missing support in Docker, you are sadly correct :disappointed:

romainverduci commented 5 years ago

I will check if I can make it work for at least the basic features.

marcuslinke commented 5 years ago

@kiview From my understanding of the problem the container used by the testcontainer framework to determine the default gateway ip must be started with logging driver "json-file" explicitly if it is supposed to deliver the ip via logging callback. Or am I missing something here?