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

时间:2019-08-25 17:19:34

标签: maven docker fabric8-maven-plugin

我无法使用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

1 个答案:

答案 0 :(得分:0)

我在拉动和推动图像时都遇到了问题,通过研究,我完全不记得自己能够通过修改Docker credentials store来解决此问题

注意执行 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钥匙链