如何将DockerHub镜像拉到GoogleCloudRun?

我正在尝试将 Docker 映像拉入 Google Cloud Run。我看到我可能需要先将它拉到 Google Container Registry,但我能以某种方式避免它吗?另外,我宁愿直接从源头获得它以使其保持最新状态。

回答

我查看了该项目,最后我在 Cloud Run 上成功运行了它

首先,您不能在Google Container Registry或Artifact Registry之外拉取镜像。所以你需要拉图像,标记它并在 GCP 中推送它(你的项目与否,但在 GCP 上)

这里的步骤

# Pull the image (I did it on Cloud Shell)
docker pull thecodingmachine/gotenberg:6

# Tag the image
docker tag thecodingmachine/gotenberg:6 gcr.io/<MY_PROJECT_ID>/thecodingmachine/gotenberg:6

#Push the image (no authentication issue on Cloud Shell)
docker push gcr.io/<MY_PROJECT_ID>/thecodingmachine/gotenberg:6

# Deploy on Cloud Run
gcloud run deploy --image=gcr.io/<MY_PROJECT_ID>/thecodingmachine/gotenberg:6 
  --port=3000 --region=us-central1 --allow-unauthenticated --platform=managed 
  --command=gotenberg gotenberg

Cloud Run 部署的技巧是:

  • 需要指定端口,不要使用默认的8080,这里是3000
  • 您需要明确指定命令。默认情况下,使用入口点 (the /tini) 并且容器应该没有很好地构建,因为存在权限问题。Dockerfile 中的更多详细信息

因此,请使用 Cloud Run URL 而不是http://localhost:3000文档中的URL并享受!

  • Works! Thank you so much.

以上是如何将DockerHub镜像拉到GoogleCloudRun?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>