从存储到运行容器的计算实例的gsutil cp不会复制文件 [英] `gsutil cp` from Storage to compute instance running container doesn't copy files

查看:125
本文介绍了从存储到运行容器的计算实例的gsutil cp不会复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行带有coreos容器(图像名称:coreos-stable-1688-4-0-v20180327)的Google计算实例.使用gsutil将文件从Storage复制到本地文件系统似乎可以正常工作-除非实际上没有任何假定复制的文件出现在文件系统上.在不使用容器的情况下在计算实例上运行相同的copy命令确实可以工作,因此我想问题出在容器上.但是,我不确定容器是什么原因导致复制失败.

I am running a Google compute instance with a coreos container (image name: coreos-stable-1688-4-0-v20180327). Copying files from Storage to the local filesystem with gsutil seems to work fine -- except that none of the supposedly copied files actually appears on the filesystem. Running the same copy command on a compute instance without using a container does work, so I imagine the issue is with the container. However, I'm not sure what about the container is causing the copy to fail.

命令是gsutil cp -r gs://my-bucket ./.

推荐答案

您遇到的问题是

You're hitting the issue described in https://github.com/GoogleCloudPlatform/gsutil/issues/453. There's an alias set up for gsutil that runs gsutil within a container (which does not have access to the host filesystem), so the files are being copied to that container's filesystem, rather than your GCE host's. Some workarounds are suggested in that thread.

编辑以更好地阅读 (来自GitHub问题线程的信息):

EDIT for better reading (info from the GitHub issue thread):

像GCE虚拟机一样,为gsutil设置了 nifty 别名:

Looks like GCE VMs have a nifty alias set up for gsutil:

$ type gsutil
gsutil is aliased to `(docker images google/cloud-sdk || docker pull google/cloud-sdk) > /dev/null;docker run -t -i --net=host -v /home/<USER>/.config:/root/.config google/cloud-sdk gsutil'

CoreOS实例上的可能的解决方法:

  • 克隆 gsutil存储库,运行git checkout <tag>来获取最新版本的提交,通过这些说明安装Python,然后确保直接在CoreOS主机上运行gsutil的本地副本,而不是运行gsutil的容器化版本.
  • 覆盖gsutil别名,或创建一个新别名,以便它将主机文件系统的某些部分安装在容器上;这样,您就可以在容器终止后访问新编写的文件.
  • Clone the gsutil repo, run git checkout <tag> to fetch the commit for the most recent release, install Python via these instructions, then make sure to run the local copy of gsutil directly on the CoreOS host, rather than running the containerized version of gsutil.
  • Override the gsutil alias, or make a new one, so that it mounts some part of the host filesystem on the container; this allows you to access the newly-written files after the container terminates.

这篇关于从存储到运行容器的计算实例的gsutil cp不会复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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