无法在Google云引擎虚拟机上的挂载存储中运行Docker容器。

huangapple go评论68阅读模式
英文:

Unable to run docker containers on the mounted storage in gce vm

问题

我们计划从本地迁移到GCP,但设计过程需要一些时间。我们希望在GCE虚拟机上部署我们的Docker容器。我们不想在容器填满空间时手动增加存储,我们知道这可以通过自动扩展来实现,但我们对此并不够了解。因此,我们发现可以将GCS挂载到虚拟机上,然后在挂载路径上运行我们的容器,但当我们尝试触及文件或运行容器时,出现了权限被拒绝的错误。有人可以帮助我们解决这个问题吗?我们尝试了许多文档和教程,但它们有点令人困惑。

我们使用gcsfuse来将存储桶挂载到GCE虚拟机。

英文:

We are planning to move from on-prem to gcp, but the process of designing is taking some time. We want to deploy our docker containers on gce vms. We don't want to manually increase the storage every time the containers fill up the space, we know that this can be done by auto scaling but we don't have enough expertise on this. So, we found out that GCS can be mounted on the VM and we can run our containers on the mounted path, but when we tried touching files or running containers we are getting permission denied error. can anyone help us to resolve it we tried many docs and tutorials but they are a little bit confusing.

We used gcsfuse for mounting the bucket to the gce vm

答案1

得分: 0

在我们的情况下,我们使用了gcsfuse将存储桶挂载到了gce实例的/root/bucketmount目录下。由于存储桶被挂载到了根文件系统,我不得不使用提升特权标签,但不建议这样做。因此,我们现在使用chown命令更改了文件夹的权限。这对我们很有帮助,因此在我们的流水线中,我们创建了3个步骤:

  1. 创建一个gcs存储桶并将其挂载到虚拟机上
  2. 检查挂载路径的权限并更新权限
  3. 部署docker容器。

截至目前,路径是硬编码的,我想要使其随机化。验证选项将在我成功后通知您。

更新

我创建了一个脚本,将由n8n webhook触发,为挂载目录创建一个随机名称,然后使用相同的脚本将目录的名称更新到一个csv文件中,我的CICD将从中获取详细信息并部署容器。

英文:

In our case we were using gcsfuse and mounted the bucket to the gce instance at /root/bucketmount. since the bucket is mounted on root fs, I have to use escalate privilege tag but it's not suggested to use. so we now changed the permissions to the folder using chown command. This helped us so In our pipeline we have created 3 steps

1 for creating a gcs bucket and mount it to the vm
2 for checking permissions for the mounted path and updating the permissions
3 for deploying the docker containers.

As of now the path is hardcoded I want to make it randomised verifing options will let you know if I succeed..

Update

I have created a script which will get triggered by n8n webhook and creates a random name for the mount directory and by using the same script the name of the directory will be updated to a csv file from which my CICD will fetch the details and deploy the containers.

huangapple
  • 本文由 发表于 2023年2月19日 12:18:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75497959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定