我是docker的新手, 我试图在Mac上运行:
docker run eloomina1 / datacollector
返回:
错误:无法访问jarfile dataCollector-0.0.1-SNAPSHOT.jar
我已经检查过,它不是该文件的权限。 我正在建立这样的图像:
docker build --build-arg JAR_FILE = dataCollector-0.0.1-SNAPSHOT.jar -t eloomina1 / datacollector。
我的dockerfile:
FROM adoptopenjdk/openjdk12:latest
MAINTAINER Shahar Wider <shahar@ttt.com>
VOLUME /tmp
ARG JAR_FILE
COPY target/${JAR_FILE} dataCollector.jar
ENTRYPOINT ["java","-jar","dataCollector-0.0.1-SNAPSHOT.jar"]
我的pom.xml:
<groupId>com.eloomina</groupId>
<artifactId>dataCollector</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>dataCollector</name>
<properties>
<java.version>12</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
<docker.image.prefix>eloomina1</docker.image.prefix>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>eloomina1/datacollector</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
我的文件系统:
├── Dockerfile
├── HELP.md
├── cd
├── dataCollector.log
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
└── target
├── dataCollector-0.0.1-SNAPSHOT-docker-info.jar
├── dataCollector-0.0.1-SNAPSHOT.jar
答案 0 :(得分:1)
图像中的jar文件的名称为dataCollector.jar
,因为您使用了COPY
这样的命令:
COPY target/${JAR_FILE} dataCollector.jar
因此ENTRYPOINT
应该是:
ENTRYPOINT ["java","-jar","dataCollector.jar"]