如何使用Maven部署到Docker Hub?

时间:2019-01-09 17:33:28

标签: maven docker

使用用于Maven的io.fabric8插件,我一直在尝试将构建的服务部署(PUSH)到我的docker-hub帐户,但是根据我的尝试,我会拒绝访问或出现其他错误。

我用〜/ .m2中的docker hub登录信息创建了“ settings.xml”文件,以便可用。

在下面的POM.XML代码中,我引用了“ serverId”标记,该标记应从〜/ .m2 / settings.xml文件中引入身份验证信息。

将感谢任何有关为什么推送不起作用的建议。

基本的构建和运行确实可以正常运行,因此只是失败而已。

非常感谢您的建议。

   <plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.26.0</version>

<executions>

    <execution>
        <id>start</id>
        <phase>pre-integration-test</phase>
        <goals>
            <goal>build</goal>
            <goal>start</goal>
        </goals>
    </execution>
    <execution>
        <id>stop</id>
        <phase>post-integration-test</phase>
        <goals>
            <goal>build</goal>
        </goals>
    </execution>

    <!--push image to docker hub-->
    <execution>
        <id>tag-image-latest</id>
        <phase>deploy</phase>
        <configuration>
            <image>services/${project.artifactId}</image>
            <newName>testsvc/services:${project.artifactId}:latest</newName>
            <pushImage>true</pushImage>
            <serverId>docker-hub</serverId>    
        </configuration>
    </execution>

</executions>

<configuration>
    <images>
        <image>
            <name>services</name>
            <build>
                <dockerFile>${project.basedir}/Dockerfile</dockerFile >
            </build>
            <run>
                <ports>
                    <port>8089:8080</port>
                </ports>
            </run>
        </image>
    </images>
</configuration>
</plugin>

0 个答案:

没有答案