我正在尝试将 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 部署的技巧是:/tini
)并且容器应该没有很好地构建,因为存在权限问题。更多详情请见 Dockerfile 因此,请使用 Cloud Run URL 而不是
http://localhost:3000
您在文档中拥有并享受!
关于docker - 如何将 Docker Hub 镜像拉到 Google Cloud Run?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66316490/