简体   繁体   English

如何在Docker中启动胖子?

[英]How to start a fat jar in docker?

I want to start my fat JAR inside a Docker container 我想在Docker容器中启动胖JAR

Docker file Docker文件

FROM java:8-jre
COPY config.yml /opt/hello/
COPY build/libs/Dockerwizard.jar /opt/hello/
EXPOSE 80
WORKDIR /opt/hello
CMD ["java", "-Xms128m", "-Xmx1500m", "-Dfile.encoding=UTF-8", "-jar", "Dockerwizard.jar", "server", "config.yml"]

Everytime I run 每次我跑步

docker build --tag=myapp .

and

docker run -p 18080:8080 -t -i myapp

I get the message 我收到消息

Error: Unable to access jarfile Dockerwizard.jar

How can I resolve this? 我该如何解决?

It says: 它说:

COPY build/libs/Dockerwizard.jar /opt/hello/
...WORKDIR /opt/chat

So you are putting the Jar into /opt/hello , but then you want to run it from /opt/chat . 因此,您要将Jar放入/opt/hello ,但随后您想从/opt/chat运行它。

Maybe you want to look into using consistent path information. 也许您想研究使用一致的路径信息。 Beyond that, when you are not using the -cp option of java, you always have the issue that your CLASSPATH might be incomplete. 除此之外,当您不使用java的-cp选项时,始终会遇到CLASSPATH可能不完整的问题。 So try adding -cp . 因此,尝试添加-cp . for example. 例如。

Try changing the WORKDIR in your Dockerfile 尝试在Dockerfile中更改WORKDIR

WORKDIR /opt/chat is incorrect WORKDIR /opt/chat不正确

It should be /opt/hello 它应该是/opt/hello

Update 更新资料

you have updated the question and renamed /chat to /hello everywhere - so you have made a correction to your error/ mistake 您已经更新了问题,并在所有地方都将/chat重命名为/hello因此您已对错误/错误进行了更正

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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