[英]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.