【问题标题】:jib-maven-plugin I/O error for image [registry-1.docker.io/library/adoptopenjdk]图像 [registry-1.docker.io/library/adoptopenjdk] 的 jib-maven-plugin I/O 错误
【发布时间】:2021-11-10 12:59:42
【问题描述】:

我开发了一个 Dockerized Spring Boot 应用程序,使用 AdoptOpenJDK 作为基础映像并使用 jib-maven-plugin

我的插件配置是:

                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>jib-maven-plugin</artifactId>
                    <version>${jib-maven-plugin.version}</version>
                    <configuration>
                        <from>
                            <image>adoptopenjdk:11-jre-hotspot</image>
                        </from>
                        <to>
                            <image>public/my-app</image>
                            <tags>
                                <tag>latest</tag>
                                <tag>${project.version}</tag>
                            </tags>
                        </to>
                        <container>
                            <entrypoint>
                                <shell>bash</shell>
                                <option>-c</option>
                                <arg>/entrypoint.sh</arg>
                            </entrypoint>
                            <ports>
                                <port>8080</port>
                            </ports>
                            <environment>
                                <SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
                                <JHIPSTER_SLEEP>0</JHIPSTER_SLEEP>
                            </environment>
                            <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
                        </container>
                        <extraDirectories>
                            <paths>src/main/jib</paths>
                            <permissions>
                                <permission>
                                    <file>/entrypoint.sh</file>
                                    <mode>755</mode>
                                </permission>
                            </permissions>
                        </extraDirectories>
                    </configuration>
                </plugin>

一切正常,启动./mvnw package -Pprod -DskipTests jib:build -T16.0C 时应用程序已正确构建。现在我正在将我的应用程序集成到 CI/CD Jenkins 管道中,并且我正在创建一个类似于第一个但使用变量传递 Auth 数据的命令:

 ./mvnw -ntp -T2.0C jib:build -Djib.from.auth.username=myUserName -Djib.from.auth.password=mygitlabtoken01 -Dimage=registry.gitlab.com/myapp -X 

当我运行它时,我得到:

[INFO] Using credentials from Docker config (/Users/myUser/.docker/config.json) for registry.gitlab.com/neoris-emea-internal/ianthe/ianthe-app/ianthe
[DEBUG] attempting bearer auth for registry.gitlab.com/app...
[INFO] The base image requires auth. Trying again for adoptopenjdk:11-jre-hotspot...
[INFO] Using credentials from <from><auth> for adoptopenjdk:11-jre-hotspot
[DEBUG] Trying basic auth for adoptopenjdk:11-jre-hotspot...
[DEBUG] configured basic auth for registry-1.docker.io/library/adoptopenjdk
[DEBUG] TIMED   Authenticating push to registry.gitlab.com : 1091.927 ms
[DEBUG] TIMED   Building and pushing image : 1122.522 ms
[ERROR] I/O error for image [registry-1.docker.io/library/adoptopenjdk]:
[ERROR]     javax.net.ssl.SSLHandshakeException
[ERROR]     Remote host terminated the handshake

我什么都不懂:

  • 如果我用-Djib.from.auth.username=myUserName 指明了身份验证信息,为什么jib 插件使用我的.docker/config.json
  • 为什么我收到SSLHandshakeException?尽管构建使用的是我的凭据,但这些都是正确的。

【问题讨论】:

    标签: docker maven jhipster jib maven-jib


    【解决方案1】:

    如果您仔细查看日志消息,Jib 确实将您通过 from.auth.username|password 指定的凭据用于adoptopenjdk(托管在 Docker Hub 上)。

    Using credentials from <from><auth> for adoptopenjdk:11-jre-hotspot
    

    请注意,以下行表示 Docker 配置用于 registry.gitlab.com(目标注册表)。

    Using credentials from Docker config (/Users/myUser/.docker/config.json) for registry.gitlab.com/neoris-emea-internal/ianthe/ianthe-app/ianthe
    

    关于SSLHandshakeException,它与任何 Docker 凭据无关。该错误来自一个低得多的网络层(TLS 协议),因此该故障与 Jib 或 Jenkins 上的 JVM 中运行的任何应用程序根本无关。它基本上告诉您,JVM 上的任何 Java 应用程序都无法与某些主机建立安全的 TLS 连接。有no simple answer or solution to a TLS handshake failure,所以如果可能的话,请向网络和 TLS 专家寻求帮助。另请查看其他 SO 问题,例如 this one

    【讨论】:

      猜你喜欢
      • 2020-07-20
      • 2019-02-14
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 2021-05-12
      • 2023-03-31
      • 2019-01-03
      相关资源
      最近更新 更多