7

我有一个构建为 docker 映像的 maven 项目。我正在使用spotify/dockerfile-maven构建此映像并将其自动推送到 docker.hub on on 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)
......

这是我的插件配置:

     <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一切正常时。

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

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

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

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

2 回答 2

3

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

<server>
      <id>docker.io</id>
      <username>xxxxx</username>
      <password>xxxxxx</password>
    </server>
于 2020-01-31T17:43:49.040 回答
-1

我假设您没有收到提示找不到 docker.io 服务器引用的错误,这意味着您的 settings.xml 凭据被选中。可能是 ${docker.image.prefix} 不是正确的 hub.docker.com 用户名。尝试对其进行硬编码,看看它是否有效。

于 2021-01-09T05:00:30.077 回答