从docker文件传递jvm参数时发生java错误
这是我的档案:
# Start with a base image containing Java runtime
FROM openjdk:8-jdk-alpine
# Add a volume pointing to /tmp
VOLUME /tmp
# Make port 8080 available to the world outside this container
EXPOSE 8080
# The application's jar file
COPY Server_Changes/glowroot /tmp
ARG JAR_FILE=target/websocket-demo-0.0.1-SNAPSHOT.jar
ARG OK=/tmp/glowroot.jar
# Add the application's jar to the container
ADD ${JAR_FILE} websocket-demo.jar
# Run the jar file
ENTRYPOINT ["java", " -javaagent:/glowroot.jar" , "- Dglowroot.agent.id=Docker "," -jar /websocket-demo.jar"]
我在构建图像时遇到以下错误:
Could not find or load main class-javaagent:.glowroot.jar
有人能解释一下原因吗
# 1 楼答案
在
RUN
、ENTRYPOINT
和CMD
命令中使用类似JSON的语法时,引号中的空格很重要。尤其是当你说空间是选项的一部分;由于该选项不是以
-
开头,Java将其解释为类名。这基本上适用于你所有的选择。在最后一个选项中,-jar
和类名是两个单独的选项,需要在两个单独的“单词”中(考虑将此
ENTRYPOINT
更改为CMD
以使映像更易于调试,并删除VOLUME
声明;它只会导致意外的奇数副作用。)