docker - 如何将 Docker Hub 镜像拉到 Google Cloud Run?

标签 docker google-cloud-platform google-cloud-run google-container-registry

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

最佳答案

我查看了该项目,最后我在 Cloud Run 上成功运行了它
首先,你不能把图片拉到外面 Google Container RegistryArtifact 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
  • 您需要明确指定命令。默认情况下,使用入口点( /tini )并且容器应该没有很好地构建,因为存在权限问题。更多详情请见 Dockerfile

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

    关于docker - 如何将 Docker Hub 镜像拉到 Google Cloud Run?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66316490/

    相关文章:

    swift - CloudRun 中的 Apple SwiftNIO - 这可能吗?

    docker - Google Drive API - 自动查询消息

    c - CMake 中的 LibSodium 依赖项无法在 Docker 容器中解析

    docker - 没有提供-i的docker -t选项有没有用例?

    mysql - docker run mysql 图像命令不起作用 [MacBook Pro M1]

    docker - 为 Cloud Run 部署公开端口 8080 和 3000

    google-cloud-platform - 错误 : (gcloud. beta.run.deploy)资源名称只能使用小写字母、数字和 '-' 。 ...最大长度为 63 个字符

    google-cloud-platform - GCP(AI 平台笔记本)上的“服务器连接错误”

    等待卷附加/挂载的 Kubernetes POD 超时已过期

    kubernetes - 不使用 gcloud sdk 连接到 Kubernetes 集群