简体   繁体   English

无法使用fabric8插件推送docker镜像

[英]Unable to push docker image with fabric8 plugin

I'm unable to push a docker image to a private repository (hosted on https://hub.docker.com ) with fabric8 plugin.我无法使用 fabric8 插件将 docker 映像推送到私有存储库(托管在https://hub.docker.com 上)。 I created on hub.docker a repository called: manuzid/heap-dump-sample .我在 hub.docker 上创建了一个名为: manuzid/heap-dump-sample的存储库。 It's a simple Spring Boot app only with a loop in the main function.这是一个简单的 Spring Boot 应用程序,仅在主函数中有一个循环。 the interesting part is the following in the pom.xml:有趣的部分是 pom.xml 中的以下内容:

<plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.27.2</version>
            <configuration>
                <registry>index.docker.io/v1</registry>
                <!-- I think it's not necessary, plugin use the creds from docker config.json -->
                <authConfig>
                    <username>user</username>
                    <password>pw</password>
                </authConfig>
                <images>
                    <image>
                        <name>manuzid/heap-dump-sample:%l</name>
                        <alias>${project.artifactId}</alias>
                        <build>
                            <from>greyfoxit/alpine-openjdk8</from>
                            <entryPoint>
                                <exec>
                                    <arg>java</arg>
                                    <arg>-jar</arg>
                                    <arg>/opt/application/${project.artifactId}-${project.version}.jar</arg>
                                    <arg>-XX:+HeapDumpOnOutOfMemoryError</arg>
                                    <arg>-XX:HeapDumpPath=/dumps/oom.hprof</arg>
                                </exec>
                            </entryPoint>
                            <tags>
                                <tag>${project.version}</tag>
                            </tags>
                            <assembly>
                                <targetDir>/opt/application</targetDir>
                                <descriptorRef>artifact</descriptorRef>
                            </assembly>
                            <env>
                                <AB_ENABLED>jmx_exporter</AB_ENABLED>
                            </env>
                        </build>
                        <run>
                            <wait>
                                <log>Started HeapDumpSampleApplication</log>
                                <time>10000</time>
                            </wait>
                            <env>
                                <JAVA_OPTIONS>-Xmx64m</JAVA_OPTIONS>
                            </env>
                            <log>
                                <file>${project.build.directory}/heap-dump-sample.log</file>
                            </log>
                        </run>
                    </image>
                </images>
            </configuration>
            <executions>
                <execution>
                    <id>docker-build</id>
                    <phase>package</phase>
                    <goals>
                        <goal>build</goal>
                    </goals>
                    <configuration>
                        <filter>${project.artifactId}</filter>
                    </configuration>
                </execution>
                <execution>
                    <id>docker-push</id>
                    <phase>install</phase>
                    <goals>
                        <goal>push</goal>
                    </goals>
                    <configuration>
                        <filter>${project.artifactId}</filter>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I get the following error in the console: [ERROR] DOCKER> Unable to push 'manuzid/heap-dump-sample:latest' from registry 'index.docker.io/v1' : denied: requested access to the resource is denied [denied: requested access to the resource is denied ]我在控制台中收到以下错误: [ERROR] DOCKER> Unable to push 'manuzid/heap-dump-sample:latest' from registry 'index.docker.io/v1' : denied: requested access to the resource is denied [denied: requested access to the resource is denied ]

But the specified credentials are the same I use to log into the website ( https://hub.docker.com ).但指定的凭据与我用于登录网站 ( https://hub.docker.com ) 的凭据相同。 The specified registry url index.docker.io/v1 is obtained with the command docker info .指定的注册表 url index.docker.io/v1是通过命令index.docker.io/v1 docker info获得的。

Any suggestions on this?对此有何建议? Thanks in advance.提前致谢。

Edit: This example can be found here: https://github.com/ManuZiD/heap-dump-sample编辑:这个例子可以在这里找到: https : //github.com/ManuZiD/heap-dump-sample

I have had issues with both pulling and pushing images and through research which I cannot fully remember I was able to resolve this issue by modifying my Docker credentials store我在拉取和推送图像方面遇到了问题,并且通过研究我无法完全记住我能够通过修改我的Docker 凭证存储来解决这个问题

Note executing docker login will create this file and also overwrite its contents ( I suggest making a backup! )请注意,执行docker login将创建此文件并覆盖其内容(我建议进行备份!

The content of config.json should be something like: config.json的内容应该是这样的:

{
    "HttpHeaders": {
        "User-Agent": "Docker-Client/19.03.12 (windows)"
    },
    "auths": {
        "https://hub.docker.com/v1/": {
            "auth": "AUTH-TOKEN"
        },
        "https://index.docker.io/v1/": {
            "auth": "AUTH-TOKEN"
        }
    },
    "credsStore": "desktop",
    "stackOrchestrator": "swarm"
}

AUTH-TOKEN needs to contain base64{docker-user-id:docker-password}: AUTH-TOKEN需要包含 base64{docker-user-id:docker-password}:

echo "docker-user-id:docker-password" | base64

Note this can be decoded using请注意,这可以使用解码

echo AUTH-TOKEN | base64 -d

Warning Never share the contents of your config.json file!警告永远不要共享 config.json 文件的内容!

This is my windows client credentials as you will notice from the user-agent details.这是我的 Windows 客户端凭据,您会从用户代理详细信息中注意到。 OSX users may prefer to utlise an OSX key-chain OSX 用户可能更喜欢使用 OSX 钥匙串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM