K. *_*ddy 7 maven spring-boot jib
我有一个简单的 SpringBoot 应用程序,我想使用Jib Maven 插件构建 docker 镜像。以下是我的插件配置:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<from>
<image>openjdk:11-jdk-slim</image>
</from>
<to>
<image>username/appname</image>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</to>
<container>
<mainClass>demo.Application</mainClass>
<ports>
<port>8080</port>
<port>8787</port>
</ports>
</container>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我只想在本地构建映像并运行它。我不想一次性构建并推送到 docker 注册表。
当我运行命令mvn jib:build 时,它会使用我来自 Docker 配置(/Users/username/.docker/config.json) 的凭据自动推送到 DockerHub 。
有没有办法可以禁用推送和另一个目标只是将图像推送到注册表?
Cha*_* Oh 18
既然你说jib:dockerBuild
这不是一个选项,那么最接近的解决方法是jib:buildTar
;目标在target/jib-image.tar
(可使用 进行配置的路径<outputPaths><tar>
)创建本地 tarball。第一次运行jib:buildTar
(或任何目标)将构建并缓存构建图像所需的所有内容。jib:...
因此,后续jib:build
运行在构建层方面将是无操作的。它只需要发送远程注册表中缺少的层。
当然,该解决方法的一个缺点是它会创建一个不必要的 tarball,该 tarball 可能很大。
与您的问题无关,您不需要设置<tag>latest</tag>
,因为目标图像引用<image>username/appname<image>
已经暗示了<image>username/appname:latest<image>
。该<tags>
配置用于将附加标签推送到 之上<to><iamge>
。
non*_*ono 10
从 JIB 文档Jib Maven Plugin,您可以运行
mvn jib:dockerBuild
Run Code Online (Sandbox Code Playgroud)
这将在构建后将镜像推送到 Docker 守护进程。
归档时间: |
|
查看次数: |
7091 次 |
最近记录: |