Docker image not getting image name from pom.xml

5.9k Views Asked by At

I am creating the docker image using spotify. My docker image is creating successfully but w/o a name. I am getting below on console:

Image will be built without a name

POM.XML

   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.nv</groupId>
    <artifactId>microeurekaserver</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>MicroEurekaServer</name>
    <description>Eureka Server</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.SR2</spring-cloud.version>
        <docker.image.prefix>nvarshney44/nvarshney</docker.image.prefix>
    </properties>


  <build>
     <plugins>
       <plugin>
         <groupId>com.spotify</groupId>
         <artifactId>docker-maven-plugin</artifactId>
         <version>1.0.0</version>

         <configuration>
            <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
            <forceTags>true</forceTags>
            <imageTags>
                <imageTag>${project.version}</imageTag>
                <imageTag>latest</imageTag>
             </imageTags>
            <resources>
               <resource>
                  <directory>${project.build.directory}</directory>
                  <include>${project.build.finalName}.jar</include>
               </resource>
            </resources>
            <serverId>docker-hub</serverId>
             <registryUrl>https://index.docker.io/v1/</registryUrl>
         </configuration>
      </plugin>

      <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
   </plugins>

</build>

Maven Output

Please help me out whats wrong with it. In maven output it is showing dockerfile:null may be it is costing some issue.

2

There are 2 best solutions below

3
On

Where are you defining this variables values ${docker} and ${project}? It's gonna be something like:

<docker> <image> <prefix> value </prefix> </image> </docker>

Please check: Using variables in pom.xml

0
On

In order to give a Docker image a name, you need to fill in the "repository" field:

<configuration>
  <repository>your-name-here</repository> <!-- ${project.artifactId} is a good choice -->
  <tag>${project.version}</tag>
</configuration>

This is actually consistent with the way Docker push works - it treats the name as the repository address.