1

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.

Nishant Varshney
  • 685
  • 2
  • 14
  • 34
  • I'm not sure but dockerfile plugin was a little simpler in my case: ` com.spotify dockerfile-maven-plugin 1.4.9 build package build foo/barrepository> ${project.version} ` Other than that I'd recommend packaging with -X flag to see more details – emrekgn Apr 10 '19 at 18:49

2 Answers2

8

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.

Omri Spector
  • 2,431
  • 24
  • 22
-1

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

YosiFZ
  • 7,792
  • 21
  • 114
  • 221
Pablo Castro
  • 134
  • 6
  • I have edited my pom.xml in question..pls check...docker.image.prefix is defined in the properties tag... – Nishant Varshney Mar 03 '19 at 14:36
  • Try to use `${parent.artifactId}` instead of `${project.artifactId}` please post your complete non-sensitve pom values. It'll help a lot – Pablo Castro Mar 03 '19 at 14:49
  • changed..but it is not taking any name.. btw I need project.artifactId as name not parent.artifactId... Both are having different values... – Nishant Varshney Mar 03 '19 at 14:54