As per the documentation https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#build-image.examples.custom-image-name if I have a default image name(ex: sivalabs/myapp) in spring-boot-maven-plugin and pass -Dspring-boot.build-image.imageName=sivalabs/myawesomeapp commandline argument then it will generate image with the name passed via commandline argument.

But, it is still generating the docker image with name sivalabs/myapp and ignoring the commandline argument spring-boot.build-image.imageName.

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <name>sivalabs/myapp</name>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Actual Result:

$ mvn spring-boot:build-image -Dspring-boot.build-image.imageName=sivalabs/myawesomeapp is generating the image with name sivalabs/myapp.

Expected Result:

I expect the commandline argument would take higher precedence and generate the image with name sivalabs/myawesomeapp

This is the case in both SpringBoot 2.7.0 and 2.7.1 too.

Comment From: wilkinsona

This is standard Maven behaviour where values in a pom take precedence over those specified on the command line. If you want a command line override to work, you should configure the image name using a property. See https://github.com/spring-projects/spring-boot/issues/23635.