azure - 如何使用 docker compose YAML 在 Azure 中挂载 docker 卷
问题描述
我正在尝试在 Azure 中部署 PosgreSQL Docker 容器。为此,我在 Azure 中创建了一个存储帐户和一个文件共享来存储 Docker 卷。
此外,我创建了 Docker Azure 上下文并将其设置为默认值。
要创建卷,我运行:
volume create volpostgres --storage-account mystorageaccount
我可以验证该卷是用docker volume ls
.
ID DESCRIPTION
mystorageaccount/volpostgres Fileshare volpostgres in mystorageaccount storage account
但是当我尝试部署时docker compose up
,我得到
could not find volume source "volpostgres"
这是不起作用的 YAML 文件。如何解决?如何正确指向音量?
version: '3.7'
services:
postgres:
image: postgres:13.1
container_name: cont_postgres
networks:
db:
ipv4_address: 22.225.124.121
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: xxxxx
volumes:
- volpostgres:/var/lib/postgresql/data
networks:
db:
driver: bridge
ipam:
driver: default
config:
- subnet: 22.225.124.121/24
volumes:
volpostgres:
name: mystorageaccount/volpostgres
解决方案
您可以按照此处的步骤操作。并且volumes
需要将 docker-compose 文件中的部分更改为:
volumes:
volpostgres:
driver: azure_file
driver_opts:
share_name: myfileshare
storage_account_name: mystorageaccount
推荐阅读
- regex - Scala:标记简单的算术表达式
- android - 我在哪里可以找到 AOSP 项目中实际实现 Android HAL 的源代码?
- angular - 在 Angular 中使用电子签名预览 PDF 文件
- node.js - 在 rhel7 上创建自定义 NodeJSDocker 镜像
- javascript - 条件 CSS 不在 React Native 中呈现
- python - Python dict 比较占用大量 CPU 资源
- dart - Dart 使用超类对象创建实例
- python-3.x - pyttsx3 与 tkinter 冲突
- visual-studio-code - vscode if/else 用户定义代码段中的条件
- reactjs - flickity 反应 asNavFor 两个导航不起作用