gpt4 book ai didi

azure - 主机路径不允许作为卷源,您需要引用 'volumes' 部分中定义的 Azure 文件共享

转载 作者:行者123 更新时间:2023-12-04 14:09:03 25 4
gpt4 key购买 nike

我的简单 docker-compose.yaml 文件:

version: '3'
services:
website:
image: php:7.4-cli
container_name: php72
volumes:
- .hi:/var/www/html
ports:
- 8000:80

在文件夹 hi/中,我只有一个 index.php,其中包含 hello world 打印内容。 (我这里还需要一个 Dockerfile 吗?)

现在我只想使用 docker compose up 运行这个容器:

$ docker compose up
host path ("/Users/xy/project/TEST/hi") not allowed as volume source, you need to reference an Azure File Share defined in the 'volumes' section

“docker compose”与 Azure 有什么关系? - 我目前不想使用 Azure 文件共享,并且我从未提及或配置过 Azure 的任何内容。我使用 $az logout 退出了 azure,但在我的 macbook 上仍然出现这个奇怪的错误。

最佳答案

我遇到了与您相同的问题,但就我而言,我尝试在 ACI 中对 MongoDB 使用 init-mongo.js 脚本。我假设您在某个时候在 Azure 环境中工作,我无法谈论该注销问题,但我可以谈论 Azure 上的卷。

如果您尝试在 Azure 中使用卷,至少根据我的经验,(无论您是否想要使用文件共享),您将需要引用 Azure 文件共享而不是主机路径。

了解有关 Azure 文件共享的更多信息:Mount an Azure file share in Azure Container Instances

同样根据Compose文件docs :

The top-level volumes key defines a named volume and references it from each service’s volumes list. This replaces volumes_from in earlier versions of the Compose file format.

所以 docker-compose 文件应该看起来像这样

docker-compose.yml

version: '3'

services:
website:
image: php:7.4-cli
container_name: php72
volumes:
- hi:/var/www/html
ports:
- 8000:80

volumes:
hi:
driver: azure_file
driver_opts:
share_name: <name of share>
storage_account_name: <name of storage account>




然后只需将您想要使用的文件/文件夹放入预先驱动卷的文件共享中即可。同样,如果您从未使用过 Azure,我不确定为什么会遇到该错误,但如果您最终确实使用 Azure 卷,这就是正确的方法。

请告诉我这是否有帮助!

关于azure - 主机路径不允许作为卷源,您需要引用 'volumes' 部分中定义的 Azure 文件共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66013253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com