简体   繁体   English

Spring 启动 Dockerfile 错误:未知指令:JAVA

[英]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.

相关问题 Java Spring 引导随机端口 Dockerfile - Java Spring Boot Random Port with Dockerfile SSLHandshakeException:证书未知(Java Spring 引导和 Android) - SSLHandshakeException: Certificate Unknown (Java Spring Boot & Android) Dockerfile Java Spring 启动 - 如何为日志添加文件夹 - Dockerfile Java Spring Boot - how to add folder for logs Java Spring 引导框架上的未知行为 - Unknown behaviour on Java Spring Boot Framework 在 docker 服务器上部署简单的 Spring 启动但得到 dockerfile 未找到错误 - Deploy simple Spring boot on docker server but getting dockerfile not found error Spring Boot:错误:代理抛出的异常:java.net.MalformedURLException:本地主机名未知 - Spring Boot : Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown Dockerfile 创建 spring 启动映像 - Dockerfile to create image of spring boot SQL错误:1054,SQLState:42S22'字段列表'中的未知列错误Java Spring Boot Mysql错误 - SQL Error: 1054, SQLState: 42S22 Unknown column in 'field list' error Java Spring Boot Mysql error 由于以下错误,无法使用我的 Java Spring Boot Docker 映像访问 oracle db:oracle.net.ns.NetException: Unknown host specified - Cant access oracle db with my Java spring boot Docker image because of the error: oracle.net.ns.NetException: Unknown host specified Spring Boot Rest API-未知字段-错误消息自定义 - Spring Boot Rest API - Unknown Field - Error Message Customization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM