部署到Google Cloud Run时Docker容器无法启动 [英] Docker container failed to start when deploying to Google Cloud Run

查看:171
本文介绍了部署到Google Cloud Run时Docker容器无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是GCP的新手,我试图通过在连接到BigQuery并写入系统时间的Docker容器中部署一个简单的R脚本来自学.我将跟随这个出色的教程: https://arbenkqiku.github.io/create-docker-image-with-r-and-deploy-as-cron-job-on-google-cloud

I am new to GCP, and am trying to teach myself by deploying a simple R script in a Docker container that connects to BigQuery and writes the system time. I am following along with this great tutorial: https://arbenkqiku.github.io/create-docker-image-with-r-and-deploy-as-cron-job-on-google-cloud

到目前为止,我有:

1.-制作了R脚本

library(bigrquery)
library(tidyverse)

bq_auth("/home/rstudio/xxxx-xxxx.json", email="xxxx@xxxx.com")

project = "xxxx-project"
dataset = "xxxx-dataset"
table = "xxxx-table"

job = insert_upload_job(project=project, data=dataset, table=table, write_disposition="WRITE_APPEND",
                values=Sys.time() %>% as_tibble(), billing=project)

2.-制作Dockerfile

2.- Made the Dockerfile

FROM rocker/tidyverse:latest

RUN R -e "install.packages('bigrquery', repos='http://cran.us.r-project.org')"

ADD xxxx-xxxx.json /home/rstudio

ADD big-query-tutorial_forQuestion.R /home/rstudio

EXPOSE 8080

CMD ["Rscript", "/home/rstudio/big-query-tutorial.R", "--host", "0.0.0.0"]

3.--在我的计算机上成功运行了本地容器,并将系统时间写入了BigQuery

3.- Successfully run the container locally on my machine, with the system time being written to BigQuery

4.-将容器推送到我在Google Cloud中的容器注册表中

4.- Pushed the container to my container registry in Google Cloud

当我尝试使用Google Cloud Console将容器部署到Cloud Run(完全托管)时,出现此错误:

When I try to deploy the container to Cloud Run (fully managed) using the Google Cloud Console I get this error: 

"Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information. Logs URL:https://console.cloud.google.com/logs/xxxxxx"

当我查看日志时,发现以下值得注意的条目:

When I review the log, I find these noteworthy entries:

1.-一条警告,上面写着容器称为出口(0)"

1.- A warning that says "Container called exit(0)"

2.-说容器沙箱"的两个错误:不支持的syscall setsockopt(0x8,0x0,0xb,0x3e78729eedc4,0x4,0x8).您很有可能可以安全地忽略此消息,这不是您要进行故障排除的任何错误的原因.请参考 https://gvisor.dev/c/linux/amd64/setsockopt以获取更多信息."

2.- Two bugs that say "Container Sandbox: Unsupported syscall setsockopt(0x8,0x0,0xb,0x3e78729eedc4,0x4,0x8). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information."

当我检查BigQuery时,我发现即使容器部署失败,系统时间也已写入表中.

When I check BigQuery, I find that the system time was written to the table, even though the container failed to deploy.

当我使用教程(8787)中指定的端口时,Cloud Run会引发有关无效的ENTRYPOINT"的错误.

When I use the port specified in the tutorial (8787) Cloud Run throws an error about an "Invalid ENTRYPOINT".

此错误是什么意思?如何解决?我非常感谢您的投入,因为我完全被卡住了!

What does this error mean? How can it be fixed? I'd greatly appreciate input as I'm totally stuck!

谢谢!

  • H.

推荐答案

John的评论是错误的正确根源:您需要公开一个侦听 $ PORT 的Web服务器,然后回答到HTTP/1 HTTP/2协议.

The comment of John is the right source of the errors: You need to expose a webserver which listen on the $PORT and answer to HTTP/1 HTTP/2 protocols.

但是,我有一个解决方案.为此,您可以使用 Cloud Build .只需使用容器名称和args(如果需要)定义您的步骤

However, I have a solution. You can use Cloud Build for this. Simply define your step with your container name and the args if needed

如果您需要有关此(奇怪的)解决方法的更多指导,请告诉我.

Let me know if you need more guidance on this (strange) workaround.

这篇关于部署到Google Cloud Run时Docker容器无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆