我正在尝试从docker文件运行Java应用程序。该应用程序通过maven运行。
当我尝试从下图中旋转一个容器时,出现以下错误。
[ERROR] error reading /root/.m2/repository/org/seleniumhq/selenium/selenium-java/3.141.59/selenium-java-3.141.59.jar; zip END header not found
[ERROR] error reading /root/.m2/repository/junit/junit/4.12/junit-4.12.jar; zip END header not found
[ERROR] error reading /root/.m2/repository/info/cukes/cucumber-java/1.2.5/cucumber-java-1.2.5.jar; zip END header not found
[ERROR] error reading /root/.m2/repository/info/cukes/cucumber-junit/1.2.5/cucumber-junit-1.2.5.jar; zip END header not found
[ERROR] error reading /root/.m2/repository/org/json/json/20180813/json-20180813.jar; zip END header not found
[ERROR] /temproj/src/test/java/pages/terms/Terms_Chrome.java:[1,1] cannot access pages.terms
[ERROR] zip END header not found
[ERROR] /temproj/src/test/java/config/RunCukesTest.java:[1,1] cannot access config
[ERROR] zip END header not found
[ERROR] /temproj/src/test/java/utils/SetProperty.java:[1,1] cannot access utils
[ERROR] zip END header not found
[ERROR] /temproj/src/test/java/pages/sign_in/SignIn.java:[1,1] cannot access pages.sign_in
[ERROR] zip END header not found
我的Docker文件
FROM maven
COPY . /temproj
RUN mkdir -p /root/.m2/repository/ \
mvn install
WORKDIR /temproj
ENTRYPOINT ["mvn", "verify"]
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.ecs.googleuat</groupId>
<artifactId>googleuat</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<sele.lib.version>3.141.59</sele.lib.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>
<package>
steps
</package>
</glue>
<outputDirectory>target/generated-test-sources/cucumber</outputDirectory>
<featuresDirectory>src/test/resources/features</featuresDirectory>
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<namingPattern>Parallel{c}IT</namingPattern>
<format>json,html</format>
<parallelScheme>FEATURE</parallelScheme>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<id>acceptance-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<forkCount>10</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.5</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- vinsdocker is org name. -->
<!-- containertest is the name of the image / application -->
<repository>chrisdocker/selcontainertest</repository>
<!-- version of your image: could be sprint11 or release5 etc -->
<tag>googletest</tag>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${sele.lib.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>${sele.lib.version}</version>
</dependency>
<!--<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>${sele.lib.version}</version>
</dependency>-->
</dependencies>
</project>
在解决此问题时,需要一些帮助,我认为这可能与容器内的用户权限有关。
答案 0 :(得分:0)
FROM maven
COPY . /app/
WORKDIR /app
RUN mvn install
ENTRYPOINT ["mvn", "verify"]
答案 1 :(得分:0)
基本Maven映像已经具有一个入口点脚本(see source)。为什么要覆盖它?请改用CMD ["mvn", "verify"]
。