简体   繁体   English

无法使用Maven插件在Docker Hub上推送图像

[英]Unable to push image on docker hub using maven plugin

I am using io.fabric8 docker-maven-plugin for building and pushing docker image to a registry hub.docker.com . 我正在使用io.fabric8 docker-maven-plugin构建并推送hub.docker.com镜像到注册表hub.docker.com The image needs to be pushed on a repository (For eg. xyz ) which lies under an organization (For eg. demo ). 需要将映像推送到位于组织(例如demo )下的存储库(例如xyz )上。 This is my plugin from pom.xml . 这是我来自pom.xml插件。

<plugin>
    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.20.1</version>
    <configuration>
        <images>
            <image>
                <name>demo/xyz:${tag}</name>
                <build>
                    <dockerFileDir>${project.basedir}/docker</dockerFileDir>
                </build>
            </image>
         </images>
     </configuration>
     <executions>
         <execution>
             <id>docker-image-build</id>
             <phase>pre-integration-test</phase>
             <goals>
                 <goal>build</goal>
             </goals>
         </execution>
         <execution>
             <id>docker-image-push</id>
             <phase>post-integration-test</phase>
             <goals>
                 <goal>push</goal>
             </goals>
         </execution>
     </executions>
 </plugin>

To push to the repo, your username should be registered with the organization. 要推送到仓库,您的用户名应在组织中注册。 Now, the docker image build part is working fine but I am unable to push the image through docker:push option. 现在,泊坞窗映像构建部分工作正常,但我无法通过docker:push选项推送映像。 I read and tried other available solutions like using 我阅读并尝试了其他可用的解决方案,例如使用

 <authConfig>
     <username></username>
     <password></password>
 </authConfig>

and added registry name in .docker/.config file but it didn't worked . 并在.docker/.config文件中添加了注册表名称,但没有成功。 I also added registry but it also didn't worked. 我还添加了注册表,但是它也没有起作用。

<registry>https://hub.docker.com</registry>

The push is working by using 推送正在通过使用

docker push 码头工人推

But its not working with the plugin. 但是它不能与插件一起使用。 Please help me. 请帮我。 Thanks. 谢谢。

We are using com.spotify docker-maven-plugin I think they aren´t much different. 我们正在使用com.spotify docker-maven-plugin我认为它们没有太大的不同。
Here is an example of our pom.xml 这是我们pom.xml的示例

<plugins>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.3</version>
            <configuration>
                <imageName>MY_REGISTRY:443/${project.artifactId}</imageName>
                <imageTags>
                    <imageTag>latest</imageTag>
                </imageTags>
                <dockerDirectory>docker</dockerDirectory>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
                <serverId>MY-REGISTRY</serverId>
                <registryUrl>https://MY_REGISTRY:443/v2/</registryUrl>
            </configuration>
            <executions>
                <execution>
                    <id>docker-build</id>
                    <phase>install</phase>
                    <goals>
                        <goal>build</goal>
                    </goals>
                </execution>

The username and password for the registry are set in the settings.xml 注册表的用户名和密码在settings.xml
Here is an example of our settings.xml 这是我们的settings.xml的示例

<server>
        <id>MY-REGISTRY</id>
        <username>my-user</username>
        <password>my-password</password>
        <configuration>
            <email>developer@my-company.com</email>
        </configuration>
    </server>

I hope this can help you to get the right configuration for your project. 我希望这可以帮助您为您的项目获得正确的配置。

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

相关问题 openshift私有docker注册表无法推送[docker-maven-plugin] - openshift private docker registry Unable to push [docker-maven-plugin] 使用 spotify/dockerfile-maven-plugin 推送 docker hub 时出错 - Error pushing docker hub using spotify/dockerfile-maven-plugin 无法使用fabric8插件推送docker镜像 - Unable to push docker image with fabric8 plugin 如何使用 jib-maven-plugin 构建 docker 镜像,但默认不推送? - How to build the docker image using jib-maven-plugin, but not push by default? 通过Maven插件生成Docker镜像 - Generate docker image by maven plugin 努力使用 spring boot maven 插件发布到 hub.docker.com - Struggling to publish to hub.docker.com with spring boot maven plugin 使用自定义名称构建 docker 映像 Spring Boot Maven 插件 - Build docker image with a custom name using Spring Boot Maven plugin 无法使用docker镜像中的sh文件执行maven命令 - Unable to execute the maven command by using the sh file in docker image 无法连接到在 Docker 容器内运行的 MySQL(使用 docker-maven-plugin 配置) - Unable to connect to MySQL running inside a Docker container (configured using docker-maven-plugin) 使用fabric8-maven-plugin将Docker映像推送到Google Container Registry? - Push Docker images to Google Container Registry using fabric8-maven-plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM