Sui*_*sse 6 azure docker docker-compose
我的简单 docker-compose.yaml 文件:
version: '3'
services:
website:
image: php:7.4-cli
container_name: php72
volumes:
- .hi:/var/www/html
ports:
- 8000:80
Run Code Online (Sandbox Code Playgroud)
在文件夹 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
Run Code Online (Sandbox Code Playgroud)
“docker compose”与 Azure 有什么关系?- 我目前不想使用 Azure 文件共享,并且我从未提及或配置过 Azure 的任何内容。我使用 $az logout 退出了 azure,但在我的 macbook 上仍然出现这个奇怪的错误。
小智 3
我遇到了与您相同的问题,但就我而言,我尝试在 ACI 中对 MongoDB 使用 init-mongo.js 脚本。我假设您在某个时候在 Azure 环境中工作,我无法谈论该注销问题,但我可以谈论 Azure 上的卷。
\n如果您尝试在 Azure 中使用卷,至少根据我的经验,(无论您是否想要使用文件共享),您将需要引用 Azure 文件共享而不是主机路径。
\n了解有关 Azure 文件共享的更多信息:在 Azure 容器实例中装载 Azure 文件共享
\n另根据 Compose 文件文档:
\n\n\n顶级卷键定义一个命名卷并从每个 service\xe2\x80\x99s 卷列表中引用它。这取代了早期版本的 Compose 文件格式中的volumes_from。
\n
所以 docker-compose 文件应该看起来像这样
\ndocker-compose.yml
\nversion: \'3\'\n\nservices:\n website:\n image: php:7.4-cli\n container_name: php72\n volumes:\n - hi:/var/www/html\n ports:\n - 8000:80\n \nvolumes:\n hi:\n driver: azure_file\n driver_opts:\n share_name: <name of share>\n storage_account_name: <name of storage account>\n\n\n\n \nRun Code Online (Sandbox Code Playgroud)\n然后,只需将您想要使用的文件/文件夹放入预先驱动卷的文件共享中即可。同样,如果您从未使用过 Azure,我不确定为什么会遇到该错误,但如果您最终确实使用了 Azure 卷,这就是正确的方法。
\n让我知道这是否有帮助!
\n| 归档时间: |
|
| 查看次数: |
3353 次 |
| 最近记录: |