简体   繁体   中英

HTTP 500 Internal Server Error : while containerizing my java web app

I am containerising my java web app, I am using spotify plugin to do so and using maven to build my project. But when I run mvn clean package docker:build it shows this error:

alesblaze is my docker hub's username

Bookstore is my project's name

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default) on project Bookstore: Exception caught: Request error: POST http://localhost:2375/build?t=alesblaze%2FBookstore : 500, body: {"message":"invalid reference format: repository name must be lowercase"}: HTTP 500 Internal Server Error

Dockerfile

FROM tomcat:8.5-alpine
EXPOSE 8080
VOLUME /volume/webapp/
COPY /target/BookStore-1.war /usr/local/tomcat/webapps/app.war
RUN sh -c 'touch /usr/local/tomcat/webapps/app.war'
ENTRYPOINT ["sh", "-c" , "java -Djava.security.edg=file:/dev/./urandom -jar /usr/local/tomcat/webapps/app.war]

Pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.codejava.javaee.bookstore</groupId>
  <artifactId>Bookstore</artifactId>
  <version>1</version>
  <packaging>war</packaging>

    <properties>
    <docker.image.prefix>alesblaze</docker.image.prefix>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.30</version>
        </dependency>
    </dependencies>  

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
        <finalName>BookStore</finalName>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>

      <plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>1.0.0</version>
    <configuration>
    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
    <dockerDirectory>Docker</dockerDirectory>
    <dockerHost>http://localhost:2375</dockerHost>
    <forceTags>true</forceTags>
    <imageTags>
    <imageTag>${project.version}</imageTag>
    <imageTag>latest</imageTag>
    </imageTags>
    <serverId>docker-hub</serverId>
    <registryUrl>https://hub.docker.com/</registryUrl>
    <resources>
    <resource>
    <targetPath>/</targetPath>
    <directory>${project.build.directory}</directory>
    <include>${project.build.finalName}.war</include>
    </resource>
    </resources>
    </configuration>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>build</goal>
    </goals>
    </execution>
    </executions>
</plugin>

    </plugins>
  </build>
</project>

The image name (ie Bookstore ) must be lowercase. See Lowercase images names in Docker

If you run:

 docker build -t Bookstore

you get the same error

invalid reference format: repository name must be lowercase

Try to change the artifactId Bookstore to lowercase.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM