[英]Spring Boot Dockerfile error: unknown instruction: JAVA
I have the following Dockerfile that I'm trying to use to containerize my Spring Boot application:我有以下 Dockerfile,我试图用它来容器化我的 Spring Boot 应用程序:
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.它将“java”作为单独的 Dockerfile 指令读取。 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.我建议使用 linter 来捕获这样的错误。
hadolint
is a good command-line linter and you can easily download Dockerfile linters for most IDEs. hadolint
是一个很好的命令行 linter,您可以轻松下载适用于大多数 IDE 的 Dockerfile linter。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.