I have the following Dockerfile that I'm trying to use to containerize my Spring Boot application:
FROM openjdk:8-jdk-alpine as myservice
COPY build/libs/my-service.jar my-service.jar
HEALTHCHECK CMD curl --fail https://localhost:9200/healthCheck || exit 1
EXPOSE 443 9200
ENTRYPOINT [
"java", \
"-Dspring.config=.", \
"-Dspring.profiles.active=local", \
"-Dkeystore.file=mykey.p12, \
"-jar", \
"my-service.jar"
]
When I run:
docker build -t myorg/my-service .
I get:
Sending build context to Docker daemon 82.5MB
Error response from daemon: Dockerfile parse error line 10: unknown instruction: "JAVA",
What's going on here?
It's reading "java" as a separate Dockerfile instruction. You need to escape the first line of your entrypoint command after [
and on your last line before ]
if you want them to be on separate lines:
ENTRYPOINT [ \
... \
]
Like this:
ENTRYPOINT [ \
"java", \
"-Dspring.config=.", \
"-Dspring.profiles.active=local", \
"-Dkeystore.file=mykey.p12, \
"-jar", \
"my-service.jar" \
]
I recommend using a linter to catch errors like this. hadolint
is a good command-line linter and you can easily download Dockerfile linters for most IDEs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.