简体   繁体   English

在 Google Cloud Run 上部署 docker 映像

[英]Deploy a docker image on Google Cloud Run

I am trying to deploy a Java Socket application that will serve incoming requests on some port over TCP.我正在尝试部署一个 Java 套接字应用程序,它将通过 TCP 为某个端口上的传入请求提供服务。 The image is building fine and the container is running as expected locally.图像构建良好,容器在本地按预期运行。

However when deploying to GCR it throws the following error但是,在部署到 GCR 时会引发以下错误

{
  "textPayload": "terminated: Application failed to start: Failed to create init process: failed to load /usr/lib/jvm/java-17-openjdk//bin/java: exec format error",
  "insertId": "631891ef0005eae9ece915df",
  "resource": {
    "type": "cloud_run_revision",
    "labels": {
      "project_id": "cumulus-0",
      "service_name": "cumulus",
      "revision_name": "cumulus-00001-hib",
      "location": "asia-south1",
      "configuration_name": "cumulus"
    }
  },
  "timestamp": "2022-09-07T12:43:27.387764458Z",
  "severity": "ERROR",
  "labels": {
    "instanceId": "00c527f6d4880e8a5a96fbdadc4536870f1e55a884c529efc6f860386bb3766d594380d65a657a35adebed119b05e2007cbef26928db216236f1641e97b306"
  },
  "logName": "projects/cumulus-0/logs/run.googleapis.com%2Fvarlog%2Fsystem",
  "receiveTimestamp": "2022-09-07T12:43:27.390641080Z"
}

Specifically - terminated: Application failed to start: Failed to create init process: failed to load /usr/lib/jvm/java-17-openjdk//bin/java: exec format error特别 - terminated: Application failed to start: Failed to create init process: failed to load /usr/lib/jvm/java-17-openjdk//bin/java: exec format error

this comes when the platform in unsupported for the jvm to run.这是在不支持 jvm 运行的平台时出现的。 But it is inside a docker container.但它位于 docker 容器内。 I dont know whats the matter with this.我不知道这是怎么回事。

Here is my Dockerfile这是我的Dockerfile

FROM alpine:latest
RUN apk update && \
    apk add openjdk17-jre=17.0.4.1_p1-r0

ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk

LABEL in.rainycloud.cumulus="hi@shantanubanerjee.com"

COPY build/libs/cumulus*.jar /usr/lib/

CMD ["/usr/lib/jvm/java-17-openjdk/bin/java", "-jar", "/usr/lib/cumulus-v0.1.jar", "in.rainycloud.cumulus.Main"]

EXPOSE 33333/tcp

Firstly, the path seems to be fishy.首先,这条路似乎很可疑。 Why do you have to provide full java bin path.为什么一定要提供完整的 java bin 路径。 If your build is depending upon some other libraries which requires c,make tools then try with full jdk too.如果您的构建依赖于其他一些需要 c 的库,请制作工具然后尝试使用完整的 jdk。

Also,check this code.另外,请检查此代码。 It provides start point for your server它为您的服务器提供起点

# java -jar /usr/local/runme/app.jar
ENTRYPOINT ["java","-jar","app.jar"]

Full code reference:https://mkyong.com/docker/docker-and-java-application-examples/完整代码参考:https://mkyong.com/docker/docker-and-java-application-examples/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM