Fixes gh-29384
Comment From: scottfrederick
@terminux Thanks for the contribution, but this change doesn't meet the requirements in the issue. With this change, a docker.host
system property or DOCKER_HOST
environment variable must be provided or the request to build an image will fail. The current code to access the Docker daemon accepts a DOCKER_HOST
environment variable or a host provided in plugin configuration and defaults to a local socket otherwise.
To properly implement this fix, more design will need to be done to pass the Docker configuration information contained in the Builder
, through the created Lifecycle
, to the created Phase
so it can be properly bound.
I'm going to close this PR for now. If you'd like to work on this more, just let us know and push more commits so we can review again.
Comment From: terminux
Thank you very much for your guidance @scottfrederick , I get it. I will reconsider how to implement it based on your suggestion.
Comment From: terminux
Hi @scottfrederick , my idea is to add a private constructor to DockerApi
and the original constructor will call it.
For example:
private final DockerHost host;
private DockerApi(HttpTransport http, DockerHost host) {
......
this.host = host;
}
or
private final String dockerHost;
private DockerApi(HttpTransport http, DockerHost host) {
......
this.dockerHost = (host != null) ? host.getAddress() : null;
}
This way you can get docker host from the DockerApi
when the Phase
is created and then pass it. I compared a few ways I can think of, this way the change is probably the smallest. I updated this commit in my repo and it's ready for your review again. Do I need to resubmit the PR ? Looking forward to your reply :)