0

我无法使用 fabric8 插件将 docker映像推送到私有存储库(托管在https://hub.docker.com上)。我在 hub.docker 上创建了一个名为: 的存储库manuzid/heap-dump-sample。这是一个简单的 Spring Boot 应用程序,仅在 main 函数中有一个循环。有趣的部分是 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>

我在控制台中收到以下错误:[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 ]

但指定的凭据与我用于登录网站 ( https://hub.docker.com ) 的凭据相同。index.docker.io/v1使用命令获取指定的注册表 url docker info

对此有何建议?提前致谢。

编辑:这个例子可以在这里找到:https ://github.com/ManuZiD/heap-dump-sample

4

1 回答 1

0

我在拉取和推送图像方面都遇到了问题,通过研究,我不完全记得我能够通过修改我的Docker 凭证存储来解决这个问题

注意执行docker login将创建此文件并覆盖其内容(我建议进行备份!

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需要包含 base64{docker-user-id:docker-password}:

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

请注意,这可以使用解码

echo AUTH-TOKEN | base64 -d

警告永远不要分享 config.json 文件的内容!

这是我的 Windows 客户端凭据,您将从用户代理详细信息中注意到。OSX 用户可能更喜欢使用 OSX 钥匙串

于 2020-09-29T14:40:24.863 回答