how can I build only one imageTag with docker-maven-plugin?

760 Views Asked by At

when I am using docker-maven-plugin,I met a problem: part of my pom.xml looks like:

   <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.4.13</version>
        <executions>
            <execution>
                <id>build-image</id>
                <phase>package</phase>
                <goals>
                    <goal>build</goal>
                </goals>
                <configuration>
                    <imageName>${full.image.name}</imageName>
                    <!-- optionally overwrite tags every time image is built with docker:build -->
                    <forceTags>true</forceTags>
                    <imageTags>
                        <imageTag>${demo.image.tag}</imageTag>
                        <!--<imageTag>latest</imageTag>-->                             
                    </imageTags>
                    <dockerDirectory>${project.basedir}/docker</dockerDirectory>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                    <buildArgs>
                        <HTTP_PROXY>${http.proxy}</HTTP_PROXY>
                        <HTTPS_PROXY>${https.proxy}</HTTPS_PROXY>
                        <!--<VERSION>${demo.image.version}</VERSION>-->
                        <!--<BUILD_NUMBER>${build.num}</BUILD_NUMBER>-->
                    </buildArgs>
                </configuration>
            </execution>
        </executions>
    </plugin>

Whether or not I add latest, when I execute command "mvn clean install" or "mvn clean install -DimageTag=1.0"(by guessing), it will build two images: 1.0 and latest, which the tag latest is not what I want. I only want 1.0 which is defined by ${demo.image.tag}.So the comment of "latest" does not work. How can I fix this problem?

So can anyone help me? Many thanks.

0

There are 0 best solutions below