docker run:Error:无法找到或加载主类com.example.ets.tsi.test.Main

时间:2019-12-20 09:45:50

标签: java docker

我正在尝试使用dockerfile和distroless运行jar。

FROM openjdk:11-jdk-slim AS build-env
RUN mkdir /opt/examples

WORKDIR /opt/examples

#Copy lib dir
ADD ./examples/target/dist/lib lib
ADD ./examples/target/test.jar lib/
ADD ./examples/config config
ADD ./examples/scripts scripts


FROM gcr.io/distroless/java:11-debug
COPY --from=build-env /opt /app
WORKDIR /app

#Jetty port available outside this container
EXPOSE 20830
CMD ["/app/lib/test.jar”]

在jar目录中,我可以清楚地看到类和清单

Manifest-Version: 1.0
Created-By: Apache Maven 3.6.1
Build-Jdk: 11.0.5
Specification-Title: test
Specification-Version: 0.0
Implementation-Title: test
Implementation-Version: PY20P2
Implementation-Vendor-Id: com.example.ets.tsi.test
Main-Class: com.example.ets.tsi.test.Main
BuildBranch: master
BuildNumber: 40884fa523128835dc51cf3ff929828be47761ba
BuildTime: Wed 2019-12-11 06:45 PM IST

运行docker时出现错误,我使用docker命令docker run -d -p 8080:20380 <image-name:latest>

0 个答案:

没有答案