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

Ser*_*hyr 7 java maven docker dockerhub maven-docker-plugin

我有一个构建为 docker 镜像的 Maven 项目。我正在使用spotify/dockerfile-maven来构建这个镜像,并在 on 上自动将它推送到 docker.hub mvn clean install。该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)
......
Run Code Online (Sandbox Code Playgroud)

这是我的插件配置:

     <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>
Run Code Online (Sandbox Code Playgroud)

docker push image-name:tag一切顺利时。

在这里我发现了类似的问题,但添加依赖项docker-client v8.8.4并没有改变任何东西。

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

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

The push refers to a repository [docker.io/my-login/my-image-name]
Run Code Online (Sandbox Code Playgroud)

rah*_*rma 3

添加<useMavenSettingsForAuth>true</useMavenSettingsForAuth>到配置标记并在 Maven settings.xml 中将服务器凭据指定为 -

<server>
      <id>docker.io</id>
      <username>xxxxx</username>
      <password>xxxxxx</password>
    </server>
Run Code Online (Sandbox Code Playgroud)