bmuschko/gradle-docker-plugin

Specifying http proxy settings for connecting to docker repo

padamide opened this issue · 3 comments

Expected Behavior

using org.gradle.jvmargs=-Dhttps.proxyHost=example.com -Dhttps.proxyPort=80 -Dhttp.proxyHost=proxy.host.example.com -Dhttp.proxyPort=80 in the gradle.properties file should make the docker image push task the specified proxy when pinging the repo

Current Behavior

met with a connection refused (proxy issue) in the following debug logs
15:35:31 2023-07-18T15:35:31.059-0400 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.wire] http-outgoing-0 << "{"errorDetail":{"message":"trying to reuse blob sha256:027bc8fdccbd38573cd9926b34078f040106011813eed2dbde06ca238275475e at destination: pinging container registry us-east4-docker.pkg.dev: Get \"[https://us-east4-docker.pkg.dev/v2/\](https://us-east4-docker.pkg.dev/v2//)": dial tcp 142.250.27.82:443: connect: connection refused"},"error":"trying to reuse blob sha256:027bc8fdccbd38573cd9926b34078f040106011813eed2dbde06ca238275475e at destination: pinging container registry us-east4-docker.pkg.dev: Get \"[https://us-east4-docker.pkg.dev/v2/\](https://us-east4-docker.pkg.dev/v2//)": dial tcp 142.250.27.82:443: connect: connection refused"}[\n]"

Context

It looks like there was an older issue #462 where another user had a similar issue. Not much came out of that thread beyond a "works on my machine" comment. However a lot has changed since then, and it seems like today the plugin uses Apache HttpComponents Client. As as far as I know, those system properties only work with the native java http client.

Is there another environment variable or system property, or some other undocumented way to specify http and https proxy settings for reaching out to a docker repo?

Steps to Reproduce (for bugs)

add org.gradle.jvmargs=-Dhttps.proxyHost=example.com -Dhttps.proxyPort=80 -Dhttp.proxyHost=proxy.host.example.com -Dhttp.proxyPort=80 to gradle.properties

be in an environment that requires a proxy to reach out to remote repository
run a task of type DockerPushImage

Your Environment

This tasks is executed from a jenkins job that runs in a docker container. In order to reach the remote docker repository it is required to go through an https proxy.

This might be related to the docker-java library and how it builds the ApacheDockerHttpClient docker-java/docker-java#2158

Yes, it looks like the Docker Java implementation does not automatically pick up system properties. I also see no method for providing proxy information in DefaultDockerClientConfig.Builder or ApacheDockerHttpClient.

I am closing this issue here. We can revisit this if Docker Java start supporting it.