gpt4 book ai didi

java - 使用 spotify/dockerfile-maven-plugin 推送 docker hub 时出错

转载 作者:行者123 更新时间:2023-12-02 02:39:57 27 4
gpt4 key购买 nike

我有一个 Maven 项目,它构建为 docker 镜像。我正在使用spotify/dockerfile-maven构建此镜像并在 mvn clean install 上自动将其推送到 docker.hub。build 阶段顺利通过。但是在 push 上我遇到了这个错误:

[ERROR] denied: requested access to the resource is denied
[WARNING] An attempt failed, will retry 1 more times
org.apache.maven.plugin.MojoExecutionException: Could not push image
at com.spotify.plugin.dockerfile.PushMojo.execute(PushMojo.java:90)
........
Caused by: com.spotify.docker.client.exceptions.DockerException: denied: requested access to the resource is denied
at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleError(LoggingProgressHandler.java:105)
at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress(LoggingProgressHandler.java:63)
......

这是我的插件配置:

     <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}-istio</repository>
<tag>latest</tag>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

使用docker push image-name:tag推送时一切正常。

Here我发现了类似的问题,但添加 docker-client v8.8.4 的依赖项不会改变任何内容。

此外,this评论建议切换到 1.3.3 版本,但这对我不起作用。

对于这两种情况,我可以在日志中看到它推送到同一个存储库:

The push refers to a repository [docker.io/my-login/my-image-name]

最佳答案

添加<useMavenSettingsForAuth>true</useMavenSettingsForAuth>到配置标签并在 maven settings.xml 中指定您的服务器凭据 -

<server>
<id>docker.io</id>
<username>xxxxx</username>
<password>xxxxxx</password>
</server>

关于java - 使用 spotify/dockerfile-maven-plugin 推送 docker hub 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47776984/

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