我有一个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]发布于 2020-02-01 01:43:49
将<useMavenSettingsForAuth>true</useMavenSettingsForAuth>添加到配置标记中,并在maven settings.xml中将服务器凭据指定为-
<server>
<id>docker.io</id>
<username>xxxxx</username>
<password>xxxxxx</password>
</server>发布于 2021-01-09 13:00:30
我假设您不会收到一个错误,指出找不到docker.io服务器引用,这意味着您的settings.xml凭据是正确选择的。可能是${docker.image.prefix}不是正确的hub.docker.com用户名。试着对它进行硬编码,看看它是否有效。
https://stackoverflow.com/questions/47776984
复制相似问题