将 Google 永久性磁盘附加到 Cloud SDK Docker 容器
Attaching a Google persistent disk to a Cloud SDK Docker container
假设我使用一个 Cloud SDK Docker 容器,它允许我 运行 各种 gcloud
命令,包括 gcloud compute disks create
创建一个 Google 永久磁盘。但是我无法在容器内附加到这个磁盘,因为 gcloud compute instances attach-disk
只适用于 GCE 实例而不适用于 Docker 容器。
有没有办法让容器附加甚至访问永久磁盘?事实上,我可以将永久性磁盘附加到任意 Linux 机器,而不仅仅是 GCE 实例吗?
我知道我可以使用 Docker 或 Kubernetes 来附加在容器启动之前固定和确定的永久磁盘,但我需要的是容器 本身 到附加到由容器代码确定的任意永久性磁盘。
Can I in fact attach persistent disks to arbitrary Linux machines, not just GCE instances?
不可以,您只能将 GCE 永久性磁盘附加到 GCE VM。
I cannot then attach to this disk within the container, since gcloud compute instances attach-disk only works on GCE instances and not Docker containers.
如果容器 运行 在 GCE VM 中,您应该能够将永久磁盘附加到托管容器的 VM。
I need is the container itself to attach to arbitrary persistent disks as determined by container code.
如果您 运行 您的容器处于特权模式,那么您应该能够 运行 在将磁盘连接到 VM 后使用适当的安装命令来安装磁盘。您可以尝试将一个卷映射到最初为空的容器,然后将 PD 挂载到该路径,但我不确定它是否会起作用。
假设我使用一个 Cloud SDK Docker 容器,它允许我 运行 各种 gcloud
命令,包括 gcloud compute disks create
创建一个 Google 永久磁盘。但是我无法在容器内附加到这个磁盘,因为 gcloud compute instances attach-disk
只适用于 GCE 实例而不适用于 Docker 容器。
有没有办法让容器附加甚至访问永久磁盘?事实上,我可以将永久性磁盘附加到任意 Linux 机器,而不仅仅是 GCE 实例吗?
我知道我可以使用 Docker 或 Kubernetes 来附加在容器启动之前固定和确定的永久磁盘,但我需要的是容器 本身 到附加到由容器代码确定的任意永久性磁盘。
Can I in fact attach persistent disks to arbitrary Linux machines, not just GCE instances?
不可以,您只能将 GCE 永久性磁盘附加到 GCE VM。
I cannot then attach to this disk within the container, since gcloud compute instances attach-disk only works on GCE instances and not Docker containers.
如果容器 运行 在 GCE VM 中,您应该能够将永久磁盘附加到托管容器的 VM。
I need is the container itself to attach to arbitrary persistent disks as determined by container code.
如果您 运行 您的容器处于特权模式,那么您应该能够 运行 在将磁盘连接到 VM 后使用适当的安装命令来安装磁盘。您可以尝试将一个卷映射到最初为空的容器,然后将 PD 挂载到该路径,但我不确定它是否会起作用。