首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Spotify dockerfile无法推送图像,资源已定义

Spotify dockerfile无法推送图像,资源已定义
EN

Stack Overflow用户
提问于 2019-06-02 17:11:48
回答 1查看 379关注 0票数 0

我使用Spotify Dockerfile maven插件,如下所示

代码语言:javascript
运行
复制
<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>
                            <goal>push</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <username>myUserName</username>
                    <password>myPassword</password>
                    <repository>dockerhubUsername/dockerhubRepo</repository>
                    <tag>latest</tag>
                    <buildArgs>
                        <JAR_FILE>${project.artifactId}.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>

因此,每当我使用mvn deploy进行构建时,我都会得到这个错误

代码语言:javascript
运行
复制
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.10:push (default) on project nepse-sim: Could not push image: denied: requested access to the resource is denied -> [Help 1]

我已经在配置中指定了dockerhub用户名和密码,但仍然收到此错误。任何帮助都将不胜感激。谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-02-02 06:45:26

首先,不要将您的凭证放在pom.xml中,因为这将是git或您正在使用的任何格式。因此,在.m2文件夹内的settings.xml中添加您的凭据。

代码语言:javascript
运行
复制
<server>
    <id>docker.io</id>
    <username>xxxxx</username>
    <password>xxxxxx</password>
</server>

在pom.xml中更改配置标签,如下所示-

代码语言:javascript
运行
复制
<configuration>
    <repository>dockerhubUsername/dockerhubRepo</repository>
    <tag>${project.version}</tag>
    <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
    <buildArgs>
        <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
    </buildArgs>
</configuration>

那么它应该是有效的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56413689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档