我正在尝试通过使用dockerfile-maven-plugin为我的spring boot maven项目构建一个docker映像。我在Windows 7上使用Docker Tool Box,并且运行良好。
我遇到了以下错误:
无法加载Google应用程序默认凭据 java.io.IOException:应用程序默认凭据不是 可用。如果它们在Google Compute Engine中运行,则可用。 否则,环境变量GOOGLE_APPLICATION_CREDENTIALS 必须定义为指向定义凭据的文件。看到 https://developers.google.com/accounts/docs/application-default-credentials 有关更多信息。
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>
我不明白为什么我们需要Google默认证书来构建本地映像。请帮助我,因为我是Docker World的新手。
答案 0 :(得分:0)
似乎是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>