gpt4 book ai didi

docker - 如何查看在我的 Google Cloud Platform Cloud Run 服务上运行的文件?

转载 作者:行者123 更新时间:2023-12-05 08:49:35 25 4
gpt4 key购买 nike

从事项目工作的团队将 docker 镜像部署到云运行服务。我没有 docker 镜像,但我可以访问 Cloud Run 服务。我可以看到日志和详细信息。我想找到那个 docker 镜像中的文件。我怎样才能访问它?例如图像包含一个 main.py 文件,现在我想访问它。

谢谢

最佳答案

由于 Cloud Run 使用 docker 镜像,您可以使用 GCP cloud shell (Cloud Shell 已经安装了 docker)。

此外,您还需要获取用于您的云运行服务的容器注册表镜像,要获取它,请按照以下步骤操作:

1.- 从 cloud run services list 中选择您的服务

2.- 在服务页面中,转到修订选项卡。

3.- 点击图片 URL。

4.- 在图片详细信息页面中,点击Show Pull Command,使用的图片将具有以下格式gcr.io/[imagename] 例如 gcr.io/cloudrun/hello:latest

在云外壳中运行以下命令

docker run -it --entrypoint sh {image-name}

例如:

docker run -it --entrypoint sh gcr.io/cloudrun/hello

此命令将在您的 docker 容器中打开一个新的 shell(退出命中,ctrl+d),运行命令 ls -lah 以查看您的文件docker 图像,使用 cat 命令查看任何文件的内容。

*您在 Google Cloud Console 中使用的 Google 帐户必须有权访问容器注册表镜像

关于docker - 如何查看在我的 Google Cloud Platform Cloud Run 服务上运行的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63747819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com