如何将Docker Hub映像拉到Google Cloud Run? [英] How to pull Docker Hub image to Google Cloud Run?

查看:57
本文介绍了如何将Docker Hub映像拉到Google Cloud Run?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Docker映像拖入Google Cloud Run.我发现我可能需要先将其拉到Google Container注册表中,但是我可以以某种方式避免使用它吗?另外,我宁愿从源头直接获得最新版本.

I'm trying to pull Docker images into Google Cloud Run. I see that I would probably need to pull it first to Google Container registry, but can I somehow avoid it? Also, I'd rather have it straight from the source to have it up-to-date.

推荐答案

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

I got a look on the project and finally I successfully run it on Cloud Run

首先,您不能将图像拉到 Google Container Registry

Firstly, you can't pull image outside Google Container Registry or Artifact Registry. So you need to pull the image, tag it and push it in GCP (your project or not, but on 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部署的窍门是:

The trick on the Cloud Run deployment is:

  • You need to specify the port, not use the default 8080, it's the 3000 here
  • You need to specify the command explicitly. By default, the entrypoint is used (the /tini) and the container should be not well built because there is permission issue. More detail in the Dockerfile

因此,请使用Cloud Run URL,而不要使用文档中提供的 http://localhost:3000

So then, use the Cloud Run URL instead of the http://localhost:3000 that you have in the documentation and enjoy!

这篇关于如何将Docker Hub映像拉到Google Cloud Run?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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