Docker Error: Could not find or load Main class Main.Main

北慕城南 提交于 2019-12-13 04:40:42

问题


I have coded this Dockerfile that makes a runnable jar out of a project and it also builds but when i try to run it, it says "Error: Could not find or load Main class Main.Main"

Dockerfile:

RUN yum install -y java-1.8.0-openjdk.x86_64  java-1.8.0-openjdk- 
devel.x86_64 && yum clean all

COPY resources /home/resources
COPY elk_casino_server /home/elk_casino_server
RUN /usr/bin/javac /home/elk_casino_server/src/Main/Main.java
RUN jar vcmf /home/elk_casino_server/src/META-INF/MANIFEST.MF 
/home/elk_casino_server/src/server.jar
/home/elk_casino_server/src/Main/Main.class 
/home/elk_casino_server/src/config.properties
CMD ["java","-jar","/home/elk_casino_server/src/server.jar"]

回答1:


Docker COPY command accepts path as a second parameter. Try changing your Dockerfile

Dockerfile

...
COPY resources /home/
COPY elk_casino_server /home/
...


来源:https://stackoverflow.com/questions/54144292/docker-error-could-not-find-or-load-main-class-main-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!