【问题标题】:In Compute Engine, my volume mount is not accessible at the specified mount path在 Compute Engine 中,无法在指定的挂载路径访问我的卷挂载
【发布时间】:2020-12-13 10:39:40
【问题描述】:

我正在尝试通过 hello-world 程序弄清楚挂载如何在 GCE 中工作。我有一个现有的图像,当我在 GCE 中创建一个 VM 实例时,我选择了这个现有的图像。对于命令,我输入 echo 和参数 "hello world"。当 VM 启动时,我可以在日志中看到打印的内容,因此我知道它运行正常。

在创建 VM 实例之前,我创建了一个标准的永久性磁盘。创建 VM 时,我选择了“添加卷”。我为该卷指定了这些详细信息:

  • 卷类型:磁盘
  • 装载路径:/hello-world-data
  • 磁盘名称:hello-world-test
  • 分区:
  • 模式:读/写

在我的 VM 运行并在日志中看到“hello world”后,我转到 VM 实例页面并在实例上选择“SSH”。这成功打开了一个云终端,我看到了正确读取<username>@hello-world-test-instance ~ $的提示。

ls -la,我没有看到我指定的卷:/hello-world-data

我想也许它在创建时会存在,所以我尝试:

cd /
mkdir hello-world-data

但我收到此错误:

mkdir: cannot create directory ‘hello-world-data’: Read-only file system

现在我很困惑。我创建了一个磁盘,指定了一个挂载路径,并选择了读/写。怎么回事?

经过一番探索,我发现这条路径存在:

/mnt/disks/gce-containers-mounts/gce-persistent-disks/hello-world-test

那是什么?没有文档告诉我这个多目录的深层路径。我看看我是否至少可以在那个目录中写任何东西:

$ cd /mnt/disks/gce-containers-mounts/gce-persistent-disks/hello-world-test
$ touch test.txt
touch: cannot touch 'test.txt': Permission denied

除此之外,我什至看不到由我的 Dockerfile 创建的可执行文件应该放在 /bin 目录中。

所以,我迷路了。哪里来的音量?为什么不在指定的挂载路径?为什么/bin 不包含 Dockerfile 创建的可执行文件?

谢谢

【问题讨论】:

  • 您使用的是哪种服务? Google Compute Engine(以及哪个操作系统)、Google Compute Engine Container OS (COS)、Google Container Engine(现在称为 Kubernetes)。不要将多个问题混为一题。而是发布多个问题。
  • @JohnHanley Google Compute Engine,正如它在帖子中所说的那样。对于引导盘操作系统,它是 GCE 默认值。我的容器的基础镜像是golang:1.13-alpine

标签: google-cloud-platform google-compute-engine google-compute-disk


【解决方案1】:

答案是,当您通过 SSH 连接到 VM 实例时,您是在将自己放入主机中,而不是直接放入容器中。

进入主机后,您可以通过 docker ps 找到容器 ID,然后通过 docker exec -it <container-id> bash 进入容器(如果您的容器安装了 bash)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    • 2017-09-19
    • 2015-08-15
    • 2021-04-11
    相关资源
    最近更新 更多