Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Docker client does not honour the -Dhttp.nonProxyHosts setting when it builds an image. #978

Closed
ytheohar opened this issue Feb 2, 2018 · 2 comments
Labels

Comments

@ytheohar
Copy link

ytheohar commented Feb 2, 2018

Description

The docker client does not honour the -Dhttp.nonProxyHosts setting, when it builds an image.

If the http.proxyHost is set, the docker client will go to the proxy even if DOCKER_HOST is in the http.nonProxyHosts.

How to reproduce

Provide the following settings for maven or java. One way to do this is to set MAVEN_OPTS or _JAVA_OPTIONS environmental variable.

-Dhttp.proxyHost=myProxyUrl -Dhttp.proxyPort=myProxyPort -Dhttps.proxyHost=myProxyUrl -Dhttps.proxyPort=myProxyPort -Dhttp.nonProxyHosts="localhost|127.0.0.1|192.168.*"

and run:
mvn dockerfile:build

The problem lies in the DefaultDockerClient.updateProxy() method. If the "http.proxyHost" is set it uses the proxy without looking at if the "http.nonProxyHosts" setting includes the docker host.

What do you expect

Successful build.

What happened instead

The HTTP response fails with 403:

ClientResponse{method=GET, uri=https://192.168.99.100:2376/version, status=403, reason=Forbidden}
Headers in the response:
{Server=[squid], Mime-Version=[1.0], Date=[Fri, 02 Feb 2018 15:21:59 GMT], Content-Type=[text/html;charset=utf-8], Content-Length=[2062], X-Squid-Error=[ERR_ACCESS_DENIED 0], Vary=[Accept-Language], Content-Language=[en], X-Cache=[MISS from proxy-1_6], Via=[1.1 proxy-1_6:8006], Connection=[keep-alive]}

Software:

  • docker version: [18.01.0-ce, build 03596f51b1]
  • Spotify's docker-client version: [8.8.1] This is the version used by dockerfile-maven-plugin:1.3.7

Full backtrace

[WARNING] An attempt failed, will retry 1 more times
org.apache.maven.plugin.MojoExecutionException: Could not build image
        at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:185)
        at com.spotify.plugin.dockerfile.BuildMojo.execute(BuildMojo.java:105)
        at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:246)
        at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:235)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: com.spotify.docker.client.exceptions.DockerRequestException: Request error: GET https://192.168.99.100:2376/version: 403, body: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
        <HEAD>
                <title>Web Page Cannot Be Displayed</title>
                <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
                <style>
                <!--

                        body {
                                font-family: Arial,Sans-serif;
                        }

                        li {
                                padding-top: 5px;
                        }

                        .messageBox {
                                BORDER-TOP: #9c9a9c 1px solid;
                                BORDER-LEFT: #9c9a9c 1px solid;
                                BORDER-RIGHT: #9c9a9c 1px solid;
                                BORDER-BOTTOM: #9c9a9c 1px solid;
                        }

                        .alertTitle
                        {
                                color: #676767;
                                FONT-SIZE: 12px;
                                font-weight: bold;
                        }

                        .alertText
                        {
                                color: #676767;
                                FONT-SIZE: 11px;
                                font-weight: normal;
                                padding-left: 15px;
                                padding-right: 15px;
                        }

                -->
                </style>
        </HEAD>
        <body>
                <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
                        <tr>
                                <td align="center" valign="center">
                                        <table>
                                                <tr>
                                                        <td>
                                                                <table border="0" class="messageBox">
                                                                        <tr>
                                                                                <td height="25">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                                <td align="center">
                                                                                        <table border="0" width="490">
                                                                                                <tr>
                                                                                                        <td class="alertTitle" align="center">
                                                                                                                <strong>Unable to display page</strong>
                                                                                                        </td>
                                                                                                </tr>
                                                                                                <tr class="spacerRow">
                                                                                                        <td></td>
                                                                                                </tr>
                                                                                                <tr>
                                                                                                        <td class="alertText" align="left">
                                                                                                                It has not been possible to display the page you requested for the following reason:
                                                                                                                <ul>

<li>Access Denied</li>
                                                                                                                </ul>
                                                                                                                Contact your system administrator if you continue to experience difficulties.
                                                                                                        </td>
                                                                                                </tr>
                                                                                        </table>
                                                                                </td>
                                                                        </tr>
                                                                        <tr>
                                                                                <td height="25">&nbsp;</td>
                                                                        </tr>
                                                                </table>
                                                        </td>
                                                </tr>
                                                <tr>
                                                        <td align="right"><asp:Label id="lblDateTime" runat="server" CssClass="AlertText" /></td>
                                                </tr>
                                        </table>
                                </td>
                        </tr>
                </table>
        </body>
</HTML>

        at com.spotify.docker.client.DefaultDockerClient.propagate(DefaultDockerClient.java:2504)
        at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:2443)
        at com.spotify.docker.client.DefaultDockerClient.version(DefaultDockerClient.java:501)
        at com.spotify.docker.client.DefaultDockerClient.authRegistryHeader(DefaultDockerClient.java:2555)
        at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1396)
        at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1365)
        at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:178)
        ... 25 more
Caused by: com.spotify.docker.client.shaded.javax.ws.rs.ForbiddenException: HTTP 403 Forbidden
        at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1005)
        at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:816)
        at org.glassfish.jersey.client.JerseyInvocation.access$700(JerseyInvocation.java:92)
        at org.glassfish.jersey.client.JerseyInvocation$5.completed(JerseyInvocation.java:773)
        at org.glassfish.jersey.client.ClientRuntime.processResponse(ClientRuntime.java:198)
        at org.glassfish.jersey.client.ClientRuntime.access$300(ClientRuntime.java:79)
        at org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:180)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:340)
        at org.glassfish.jersey.client.ClientRuntime$3.run(ClientRuntime.java:210)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
beskow pushed a commit to beskow/docker-client that referenced this issue Feb 28, 2018
@beskow
Copy link

beskow commented Feb 28, 2018

This became a stopper for me as well. The fix was quite straight-forward, I've just issued a pull request.

/Björn

@stale
Copy link

stale bot commented Sep 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 24, 2018
@stale stale bot closed this as completed Oct 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants