1

This is my Dockefile :

# 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"]

I am getting the following error when building the image:

Could not find or load main class-javaagent:.glowroot.jar

can someone please explain why ?

1 Answer 1

1

When you use the JSON-like syntax in RUN, ENTRYPOINT, and CMD commands, the spaces inside the quotes matter. In particular, when you say

ENTRYPOINT ["java", " -javaagent:/glowroot.jar" , ...]
#                    ^

The space is part of the option; and since the option doesn't start with a -, Java interprets it as a class name. This is basically true of all of your options. In the final option, -jar and the class name are two separate options and need to be in two separate "words".

(Consider changing this ENTRYPOINT to a CMD to make the image easier to debug, and removing the VOLUME declaration; it will only cause unexpected odd side effects.)

CMD ["java", "-javaagent:/glowroot.jar",
     "-Dglowroot.agent.id=Docker",
     "-jar", "/websocket-demo.jar"]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.