简体   繁体   English

如何将 docker 容器目录复制到 Google Compute Engine 实例

[英]How to copy docker container directories to Google Compute Engine instance

I'm new to Google Cloud and Docker and I can't for the life of me figure out how to copy directories from the Docker container (pushed to the Container Registry) to the Google Compute Engine instance.我是 Google Cloud 和 Docker 的新手,我一生都无法弄清楚如何将目录从 Docker 容器(推送到容器注册表)复制到 Google Compute Engine 实例。 I think I need to mount the volume but I don't really know how.我想我需要安装卷,但我真的不知道如何。 In the docker container the main directory is /app which has my files.在 docker 容器中,主目录是 /app,其中包含我的文件。 Basically I want to do this to see the docker container's files in Google Cloud.基本上我想这样做是为了在 Google Cloud 中查看 docker 容器的文件。

I assumed that if i did: docker pull [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG] inside the cloud shell that the files would show up somewhere in the cloud shell ie in var/lib/docker but when I cd to var/lib/docker and type in: ls I get我假设如果我这样做了: docker pull [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG] inside the cloud shell 文件将显示在 cloud shell 中的某处,即在 var/lib/docker 中,但是当我 cd 到 var/lib/docker 并输入:ls 我得到

ls: cannot open directory '.': Permission denied

Just to add I've tried following the "Connecting to Cloud Storage buckets" tutorial https://cloud.google.com/compute/docs/disks/gcs-buckets But realised that this is for single files.只是补充一下,我尝试按照“连接到云存储桶”教程https://cloud.google.com/compute/docs/disks/gcs-buckets但意识到这是针对单个文件的。 Is it possible to copy over the whole root directory of the Docker image using gsutil?是否可以使用 gsutil 复制 Docker 镜像的整个根目录? Do I need to use something else instead, like persistent disks?我是否需要使用其他东西,例如永久性磁盘?

You need to have docker installed in order to run your images and of course be able to copy anything from inside the image to your host filesystem.您需要安装 docker 才能运行您的图像,当然还可以将图像内部的任何内容复制到您的主机文件系统。

Use docker cp CONTAINER:SRC_PATH DEST_PATH to copy files.使用docker cp CONTAINER:SRC_PATH DEST_PATH复制文件。

Have a look at the official Docker Documentation on how to use this command.查看官方Docker 文档,了解如何使用此命令。 Simillar topic was also discussed here on StackOverflow and has a very good answer.在 StackOverflow 上讨论了类似的主题,并有一个很好的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Docker卷复制到Google计算引擎实例 - Copy docker volume to google compute engine instance Boot2Docker到Google Compute Engine VM:保存Docker容器 - Boot2Docker to Google Compute Engine VM: saving Docker container 如何在Google Cloud上Compute Engine VM上的容器优化操作系统中的docker中运行docker? - How to run docker in docker in Container-optimized OS on Compute Engine VM on Google Cloud? docker 容器上的应用程序的 Google Compute 引擎的 Firestore 授权 - Firestore authorization for Google Compute engine for app on a docker container 用于计算引擎上的Google CloudML的Docker容器 - 对安装存储桶进行身份验证 - Docker container for google cloudML on compute engine - authenticating for mounting bucket 有没有办法将容器从 docker hub 直接部署到谷歌计算引擎? - Is there a way to directly deploy a container from docker hub to google compute engine? 无法从Google计算引擎实例运行gcloud docker push - Unable to run gcloud docker push from google compute engine instance 如何停止和重新启动运行Docker容器的Compute Engine VM - How to stop and restart a Compute Engine VM that runs a Docker container 如何使用Docker从GitLab CI部署到Google Container Engine实例? - How do i deploy from GitLab CI to Google Container Engine instance using Docker? 如何在Docker容器中复制除任一目录之外的目录? - How to copy directories in docker container except any one directory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM