GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.67k stars 1.44k forks source link

dockerBuild does not pull base image behind corporate proxy #1403

Closed fjakop closed 5 years ago

fjakop commented 5 years ago

Description of the issue: A dockerBuild fails on Windows 10 behind a corporate proxy. The docker registry can not be reached.

Expected behavior: The maven build should pull the base image and use the proxy settings in settings.xml

Steps to reproduce:

Environment:

Windows 10

java -version

openjdk version "1.8.0_192"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_192-b12)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.192-b12, mixed mode)

docker info

Containers: 7
 Running: 1
 Paused: 0
 Stopped: 6
Images: 10
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d032b0b
ID: LERF:MQOZ:ZG6J:LWNI:NJ7Z:QY6A:RS6U:ZMF5:45O5:526Y:BN6L:ZAOU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 28
 Goroutines: 52
 System Time: 2019-01-10T08:45:11.253532Z
 EventsListeners: 1
HTTP Proxy: 172.20.249.23:8080
HTTPS Proxy: 172.20.249.23:8080
No Proxy: localhost;127.0.0.1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

mvn -version

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: C:\Entwicklung\Java\apache-maven-3.5.0\bin\..
Java version: 1.8.0_192, vendor: Oracle Corporation
Java home: C:\Entwicklung\Java\jdk8u192-b12\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Log output:

[INFO] --- jib-maven-plugin:1.0.0-rc1:dockerBuild (default-cli) @ dockertest ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=105, ConflictIdSorter.graphTime=1, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=49, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=2, ConflictResolver.conflictItemCount=102, DefaultDependencyCollector.collectTime=254, DefaultDependencyCollector.transformTime=3}
[DEBUG] com.google.cloud.tools:jib-maven-plugin:jar:1.0.0-rc1:
[DEBUG]    com.google.http-client:google-http-client:jar:1.23.0:compile
[DEBUG]       com.google.code.findbugs:jsr305:jar:1.3.9:compile
[DEBUG]       org.apache.httpcomponents:httpclient:jar:4.0.1:compile
[DEBUG]          org.apache.httpcomponents:httpcore:jar:4.0.1:compile
[DEBUG]          commons-logging:commons-logging:jar:1.1.1:compile
[DEBUG]          commons-codec:commons-codec:jar:1.3:compile
[DEBUG]    org.apache.commons:commons-compress:jar:1.18:compile
[DEBUG]    com.google.guava:guava:jar:23.5-jre:compile
[DEBUG]       org.checkerframework:checker-qual:jar:2.0.0:compile
[DEBUG]       com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
[DEBUG]       com.google.j2objc:j2objc-annotations:jar:1.1:compile
[DEBUG]       org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[DEBUG]    com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
[DEBUG]       com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[DEBUG]       com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
[DEBUG]    org.javassist:javassist:jar:3.22.0-GA:compile
[DEBUG]    org.apache.maven:maven-plugin-api:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-model:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-artifact:jar:3.5.2:compile
[DEBUG]       org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.3:compile
[DEBUG]          javax.enterprise:cdi-api:jar:1.0:compile
[DEBUG]             javax.annotation:jsr250-api:jar:1.0:compile
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:3.1.0:compile
[DEBUG]       org.codehaus.plexus:plexus-classworlds:jar:2.5.2:compile
[DEBUG]    org.apache.maven:maven-core:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-settings:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-settings-builder:jar:3.5.2:compile
[DEBUG]          org.codehaus.plexus:plexus-interpolation:jar:1.24:compile
[DEBUG]          org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile
[DEBUG]             org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG]       org.apache.maven:maven-builder-support:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-model-builder:jar:3.5.2:compile
[DEBUG]       org.apache.maven:maven-resolver-provider:jar:3.5.2:compile
[DEBUG]       org.apache.maven.resolver:maven-resolver-impl:jar:1.1.0:compile
[DEBUG]       org.apache.maven.resolver:maven-resolver-api:jar:1.1.0:compile
[DEBUG]       org.apache.maven.resolver:maven-resolver-spi:jar:1.1.0:compile
[DEBUG]       org.apache.maven.resolver:maven-resolver-util:jar:1.1.0:compile
[DEBUG]       org.apache.maven.shared:maven-shared-utils:jar:3.1.0:compile
[DEBUG]          commons-io:commons-io:jar:2.5:compile
[DEBUG]       org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.3:compile
[DEBUG]       com.google.inject:guice:jar:no_aop:4.0:compile
[DEBUG]          aopalliance:aopalliance:jar:1.0:compile
[DEBUG]       javax.inject:javax.inject:jar:1:compile
[DEBUG]       org.codehaus.plexus:plexus-component-annotations:jar:1.7.1:compile
[DEBUG]       org.apache.commons:commons-lang3:jar:3.5:compile
[DEBUG]    org.apache.maven.shared:maven-verifier:jar:1.6:compile
[DEBUG]       junit:junit:jar:3.8.2:compile
[DEBUG] Created new class realm plugin>com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1
[DEBUG] Importing foreign packages into class realm plugin>com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1
[DEBUG]   Included: com.google.cloud.tools:jib-maven-plugin:jar:1.0.0-rc1
[DEBUG]   Included: com.google.http-client:google-http-client:jar:1.23.0
[DEBUG]   Included: com.google.code.findbugs:jsr305:jar:1.3.9
[DEBUG]   Included: org.apache.httpcomponents:httpclient:jar:4.0.1
[DEBUG]   Included: org.apache.httpcomponents:httpcore:jar:4.0.1
[DEBUG]   Included: commons-logging:commons-logging:jar:1.1.1
[DEBUG]   Included: commons-codec:commons-codec:jar:1.3
[DEBUG]   Included: org.apache.commons:commons-compress:jar:1.18
[DEBUG]   Included: com.google.guava:guava:jar:23.5-jre
[DEBUG]   Included: org.checkerframework:checker-qual:jar:2.0.0
[DEBUG]   Included: com.google.errorprone:error_prone_annotations:jar:2.0.18
[DEBUG]   Included: com.google.j2objc:j2objc-annotations:jar:1.1
[DEBUG]   Included: org.codehaus.mojo:animal-sniffer-annotations:jar:1.14
[DEBUG]   Included: com.fasterxml.jackson.core:jackson-databind:jar:2.9.6
[DEBUG]   Included: com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0
[DEBUG]   Included: com.fasterxml.jackson.core:jackson-core:jar:2.9.6
[DEBUG]   Included: org.javassist:javassist:jar:3.22.0-GA
[DEBUG]   Included: javax.enterprise:cdi-api:jar:1.0
[DEBUG]   Included: javax.annotation:jsr250-api:jar:1.0
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.1.0
[DEBUG]   Included: org.codehaus.plexus:plexus-interpolation:jar:1.24
[DEBUG]   Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4
[DEBUG]   Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG]   Included: org.apache.maven:maven-builder-support:jar:3.5.2
[DEBUG]   Included: org.apache.maven.resolver:maven-resolver-util:jar:1.1.0
[DEBUG]   Included: org.apache.maven.shared:maven-shared-utils:jar:3.1.0
[DEBUG]   Included: commons-io:commons-io:jar:2.5
[DEBUG]   Included: org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.3
[DEBUG]   Included: com.google.inject:guice:jar:no_aop:4.0
[DEBUG]   Included: aopalliance:aopalliance:jar:1.0
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:1.7.1
[DEBUG]   Included: org.apache.commons:commons-lang3:jar:3.5
[DEBUG]   Included: org.apache.maven.shared:maven-verifier:jar:1.6
[DEBUG]   Included: junit:junit:jar:3.8.2
[DEBUG] Configuring mojo com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1:dockerBuild from plugin realm ClassRealm[plugin>com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1, parent: sun.misc.Launcher$AppClassLoader@7852e922]
[DEBUG] Configuring mojo 'com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1:dockerBuild' with basic configurator -->
[DEBUG]   (f) allowInsecureRegistries = false
[DEBUG]   (f) project = MavenProject: de.jakop:dockertest:0.0.1-SNAPSHOT @ C:\Entwicklung\git-repositories\de.jakop.micro\dockertest\pom.xml
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@7bf9b098
[DEBUG]   (f) skip = false
[DEBUG] -- end configuration --
[DEBUG] Searching for main class... Add a 'mainClass' configuration to 'jib-maven-plugin' to improve build speed.
[DEBUG] Could not find a valid main class specified in 'maven-jar-plugin'; attempting to infer main class.
[INFO] 
[INFO] Containerizing application to Docker daemon as dockertest:0.0.1...
[DEBUG] Containerizing application with the following files:
[DEBUG]     Classes:
[DEBUG]         C:\Entwicklung\git-repositories\de.jakop.micro\dockertest\target\classes\TestApp.class
[WARNING] Base image 'gcr.io/distroless/java' does not use a specific image digest - build may not be reproducible
[DEBUG] TIMING  Building image to Docker daemon
[INFO] Executing tasks:
[INFO] [                                                  ] 0,0% complete
[INFO] > building image to Docker daemon
[INFO] 
[INFO] Executing tasks:
[INFO] [                                                  ] 0,0% complete
[INFO] > pulling base image manifest
[INFO] 
[DEBUG] TIMING  Pulling base image manifest
[INFO] Executing tasks:
[INFO] [                                                  ] 0,0% complete
[INFO] > pulling base image manifest
[INFO] 
[INFO] Executing tasks:
[INFO] [                                                  ] 0,0% complete
[INFO] > pulling base image manifest
[INFO] > setting up to build application layers
[INFO] 
[DEBUG] TIMING  Building application layers
[INFO] Executing tasks:
[INFO] [                                                  ] 0,0% complete
[INFO] > pulling base image manifest
[INFO] > setting up to build application layers
[INFO] 
[DEBUG] TIMED   Building application layers : 0.0 ms
[INFO] Executing tasks:
[INFO] [                                                  ] 0,0% complete
[INFO] > pulling base image manifest
[INFO] > setting up to build application layers
[INFO] 
[INFO] Executing tasks:
[INFO] [=======                                           ] 13,3% complete
[INFO] > pulling base image manifest
[INFO] > building classes layer
[INFO] 
[DEBUG] TIMING  Building classes layer
[INFO] Executing tasks:
[INFO] [=======                                           ] 13,3% complete
[INFO] > pulling base image manifest
[INFO] > building classes layer
[INFO] 
[DEBUG] Building classes layer built sha256:8503f27d6cfd2e18c6a2eb056fb59e672647c1c41944e47449ed8f79f568052d
[INFO] Executing tasks:
[INFO] [=======                                           ] 13,3% complete
[INFO] > pulling base image manifest
[INFO] > building classes layer
[INFO] 
[DEBUG] TIMED   Building classes layer : 436.0 ms
[INFO] Executing tasks:
[INFO] [=======                                           ] 13,3% complete
[INFO] > pulling base image manifest
[INFO] > building classes layer
[INFO] 
[INFO] Executing tasks:
[INFO] [========                                          ] 16,7% complete
[INFO] > pulling base image manifest
[INFO] 
[DEBUG] TIMED   Pulling base image manifest : 20585.0 ms
[INFO] Executing tasks:
[INFO] [========                                          ] 16,7% complete
[INFO] > pulling base image manifest
[INFO] 
[INFO] Executing tasks:
[INFO] [=================                                 ] 33,3% complete
[INFO] > building image to Docker daemon
[INFO] 
[INFO] Executing tasks:
[INFO] [=========================                         ] 50,0% complete
[INFO] > building image to Docker daemon
[INFO] 
[DEBUG] TIMED   Building image to Docker daemon : 20596.0 ms
[INFO] Executing tasks:
[INFO] [=========================                         ] 50,0% complete
[INFO] > building image to Docker daemon
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.571 s
[INFO] Finished at: 2019-01-10T09:39:16+01:00
[INFO] Final Memory: 19M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1:dockerBuild (default-cli) on project dockertest: Build to Docker daemon failed: Connect to gcr.io/74.125.140.82:443 timed out -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1:dockerBuild (default-cli) on project dockertest: Build to Docker daemon failed
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    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:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    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: org.apache.maven.plugin.MojoExecutionException: Build to Docker daemon failed
    at com.google.cloud.tools.jib.maven.BuildDockerMojo.execute(BuildDockerMojo.java:148)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to gcr.io/74.125.140.82:443 timed out
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:335)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:123)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
    at com.google.api.client.http.apache.ApacheHttpRequest.execute(ApacheHttpRequest.java:65)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981)
    at com.google.cloud.tools.jib.http.Connection.send(Connection.java:207)
    at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:232)
    at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.callWithAllowInsecureRegistryHandling(RegistryEndpointCaller.java:152)
    at com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:142)
    at com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:356)
    at com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:202)
    at com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:210)
    at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImage(PullBaseImageStep.java:213)
    at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:126)
    at com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:59)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:127)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:80)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Additional Information:

chanseokoh commented 5 years ago

Hi @fjakop,

Can you post the result of mvn -U help:effective-settings at the project root, stripping sensitive info? Also, does it have <username> and <password>, and if so, is the password encrypted?

Lastly, can you also try setting the proxy properties on the command line to see if it works? Like mvn -U -Dhttp.proxyHost=.... Do this for both HTTP and HTTPS (http.xxx and https.xxx).

fjakop commented 5 years ago
<?xml version="1.0" encoding="Cp1252"?>
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Generated by Maven Help Plugin on 2019-01-14T13:08:34+01:00            -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/                -->
<!--                                                                        -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Effective Settings for 'me' on 'computer'                  -->
<!--                                                                        -->
<!-- ====================================================================== -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository>c:\my\apache-maven-repository</localRepository>
  <proxies>
    <proxy>
      <host>172.x.x.x</host>
      <nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
    </proxy>
  </proxies>
  <servers>
    <server>
      <username>foo</username>
      <password>***</password>
      <id>nexus-ee</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots />
          <id>snapshots2</id>
          <url>http://my-nexus:8081/nexus/content/groups/public-snapshots/</url>
        </repository>
        <repository>
          <id>releases</id>
          <url>http://my-nexus:8081/nexus/content/groups/public/</url>
        </repository>
        <repository>
          <id>ee</id>
          <url>http://my-nexus:8081/nexus/content/repositories/ee</url>
        </repository>
      </repositories>
      <id>abc</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>abc</activeProfile>
  </activeProfiles>
  <pluginGroups>
    <pluginGroup>org.apache.maven.plugins</pluginGroup>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
  </pluginGroups>
</settings>
fjakop commented 5 years ago

Specifying both -Dhttp.proxy...= and -Dhttps.proxy...= seems to work.

chanseokoh commented 5 years ago

@fjakop I think the following will work. You need to specify <protocol>, and for both HTTP and HTTPS proxying.

  <proxies>
    <proxy>
      <id>for-https-proxying</id> <!-- Make sure you use different IDs -->
      <!-- For HTTPS proxying. AFAIK, the Maven doc is wrong about this. -->
      <protocol>https</protocol>
      <host>172.x.x.x</host>
      <nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
    </proxy>
    <proxy>
      <id>for-http-proxying</id>
      <protocol>http</protocol>  <!-- for HTTP proxying  -->
      <host>172.x.x.x</host>
      <nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
    </proxy>
  </proxies>
briandealwis commented 5 years ago

The Maven settings.xml doc suggests the default for an absent protocol is for http.

chanseokoh commented 5 years ago

I will have to double check, but probably we are getting the default value (http) for <protocol> from the Maven API.

However, in this issue (and in most usual cases I think) the https needs to be defined too.

UPDATED: confirmed. Jib gets http when not specified. However, users should have a proxy entry for https too in almost all cases.

chanseokoh commented 5 years ago

@fjakop just in case, add different <id> values to both. I've seen somewhere that it may work in a weird way when using the same <id> value.

chanseokoh commented 5 years ago

Yeah, definitely add different <id> values. I see that if I use the same value, looks like the Maven API ignores the second proxy setting. I've updated the example in https://github.com/GoogleContainerTools/jib/issues/1403#issuecomment-454055859.

SlimenTN commented 3 years ago

@fjakop how exactly did you -Dhttp.proxy...= and -Dhttps.proxy...= ? I'm trying to build docker image within a coporate proxy like so: mvn compile jib:dockerBuild how can I add those attributes to the command ?

chanseokoh commented 3 years ago

https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html

@SlimenTN like mvn -Dhttp.proxyHost=my.company.proxy.com -Dhttp.proxyPort=... -Dhttps.proxyHost=... compile ....

stephan-uhlmann commented 1 year ago

I will have to double check, but probably we are getting the default value (http) for <protocol> from the Maven API.

However, in this issue (and in most usual cases I think) the https needs to be defined too.

UPDATED: confirmed. Jib gets http when not specified. However, users should have a proxy entry for https too in almost all cases.

I found this older issue, because I had the same problem as @fjakop . I think the advice/solution to add an https entry in the settings.xml is misleading.

According to https://maven.apache.org/settings.html#proxies the protocol is the protocol for connecting to the proxy. It's not the protocol of the target URL.

When I add an additional https entry in my settings.xml I get problems with connection to https:// URLs, because in my case the proxy is always using an http connection, also for https:// target URLs. The https entry breaks this.

So I think jib should not ignore a proxy entry with http protocol for https:// target URLs (from the above that's what I understood is happening, please correct me if it's wrong). Other connections to https:// URLs initiated by Maven are working. So to me it looks like a jib bug. Maybe you could check this again @chanseokoh ?

A workaround which worked for me was setting MAVEN_ARGS with the -Dhttp.* and -Dhttps.* properties.

UPDATE: just found #3796 ... better to follow-up there. Sorry for the noise.

chanseokoh commented 1 year ago

Take a look at this:

https://github.com/GoogleContainerTools/jib/pull/1337#issuecomment-447052026