docker - 图像 [registry-1.docker.io/library/adoptopenjdk] 的 jib-maven-plugin I/O 错误
问题描述
我开发了一个 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
我一点都不明白:
.docker/config.json
如果我已经用 指示了身份验证信息,为什么 jib 插件正在使用我的-Djib.from.auth.username=myUserName
?- 为什么我会得到
SSLHandshakeException
?尽管构建使用的是我的凭据,但这些都是正确的。
解决方案
如果您仔细查看日志消息,Jib 确实使用了您通过from.auth.username|password
for 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 连接。TLS 握手失败没有简单的答案或解决方案,因此请尽可能向网络和 TLS 专家寻求帮助。还可以查看其他类似这样的问题。
推荐阅读
- python - 如何在 python 中安装 plyer 库?我已经安装了 plyer 模块,仍然收到“没有模块错误”
- python - 在 python 中创建我自己的过滤器函数
- nginx - 在 Gatsby 站点上关闭 GraphQL api 的 nginx 身份验证
- html - 将 youtube iframe 视频的长度写入页面
- java - 将应用程序 docker 化会增加应用程序的启动时间吗?
- java - 字符串迭代器到字节输入流
- python - 如何在 Python 中获取第一个键值对的值
- python-3.x - 动态创建的标签不会显示在屏幕上pyqt5
- python - 解压导致 ValueError 的 zip 对象
- javascript - Express Throws TypeError:无法读取未定义的属性“应用程序”