gpt4 book ai didi

maven - 构建 Spring Boot 应用程序的 Docker 镜像文件

转载 作者:行者123 更新时间:2023-12-02 18:36:49 26 4
gpt4 key购买 nike

我正在尝试使用 dockerfile-maven-plugin 为我的 spring boot maven 项目构建一个 docker 镜像。我在 Windows 7 上使用 Docker Tool Box,它运行良好。

我遇到以下错误:

Failed to load Google application default credentials java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

Pom.XML 构建

<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>docker-hub</serverId>
<repository>${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>D:\spring\MicroServiceOutput</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>

我不明白为什么我们需要谷歌默认凭证来构建本地镜像。请帮助我,因为我是 Docker World 的新手。

最佳答案

这似乎是一个 bug ,默认情况下,插件将 googleContainerRegistryEnabled 标志设置为 true,因此您必须将该标志更改为 false,试试这个:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.RC2</spring-cloud.version>
<docker.image.prefix>prefix</docker.image.prefix>
<docker.image.name>${project.artifactId}</docker.image.name>
<docker.image.tag>${project.version}</docker.image.tag>
<docker.file>Dockerfile</docker.file>
</properties>
...
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<configuration>
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
<repository>${docker.image.prefix}/${docker.image.name}</repository>
<tag>${docker.image.tag}</tag>
<dockerfile>${docker.file}</dockerfile>
</configuration>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
<goal>tag</goal>
</goals>
</execution>
<execution>
<id>push</id>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>

关于maven - 构建 Spring Boot 应用程序的 Docker 镜像文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54769080/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com