gesellix/docker-client

dockerHost inconsistency between DockerEnv and httpClient

b4nst opened this issue · 5 comments

b4nst commented

I'm running into a strange behavior using dockerClient (through docker gradle plugin)

buildscript {
  repositories {
    maven {
      url 'https://plugins.gradle.org/m2/'
    }
  }
  dependencies {
    classpath 'de.gesellix:gradle-docker-plugin:2017-10-05T20-48-17'
  }
}

apply plugin: de.gesellix.gradle.docker.DockerPlugin

import de.gesellix.gradle.docker.tasks.DockerTask
task info(type: DockerTask){
    dockerHost 'http://10.30.0.129:2375'
    doLast{
        def client = getDockerClient()
        println client.httpClient.dockerClientConfig.env.dockerHost . // unix:///var/run/docker.sock
        println client.dockerClientConfig.env.dockerHost              // unix:///var/run/docker.sock
        println client.env.dockerHost                                 // http://10.30.0.129:2375
    }
}

I can't understand why the dockerHost is inconsistent between client.env and client.dockerClient If I run a task (e.g. DockerPsTask), it will be executed locally and not on the host I want (obviously since the httpClient target is the unix sock). Did I miss something ?

Thanks for noticing this - you found a bug. I also cannot understand how that happens. As far as I can see, the actual DockerEnv instance isn't properly passed down to the http client and another one is used.
I'll investigate and come back here when I have found the cause.

@bastienar I've found the issue, which I will fix in the plugin, first. See gesellix/gradle-docker-plugin#64 for the more specific issue.

I'll keep this issue opened, until I've found a way to handle that case not only in the plugin, but in the client itself.

The fixed client is available as:

compile 'de.gesellix:docker-client:2017-12-28T22-50-08'
b4nst commented

Great ! thanks for your reactivity