【发布时间】:2021-06-18 03:42:35
【问题描述】:
我一直在尝试使用我的 API 设置我的 Postgresql 数据库。我的 API 在 Azure WebApps 上,数据库在 Azure 文件共享上。
以下是我的 docker compose 文件
version: '3.3'
services:
db:
image: postgres
volumes:
- db_path:/var/lib/postgresql/data
restart: always
environment:
POSTGRES_USER: dbuser
POSTGRES_PASSWORD: dbuser's_password
POSTGRES_DB: db_1
api:
depends_on:
- db
image: <my registry>.azurecr.io/api:latest
ports:
- "80:80"
restart: always
它确实已部署,但我在 Azure 文件共享的位置找不到我的数据库文件。现在在重新部署时,我可以在Log Stream 中看到以下内容。
谁能告诉我我哪里做错了?为什么我的数据库不在我的 Azure 文件共享中?
提前致谢
编辑:
我还更新了我的 docker-compose.yml 文件,如下所示。我所做的更改是保持我的卷名与映射名相同,并添加了driver_opts:
version: '3.8'
services:
db:
image: mysql
volumes:
- mysql:/var/lib/mysql
environment:
- MYSQL_DATABASE=dbName
- MYSQL_ROOT_PASSWORD=MyRootPassword!
- MYSQL_USER=dbUser_1
- MYSQL_PASSWORD=dbUser_1'sPassword
restart: always
api:
depends_on:
- db
entrypoint: ["./wait_for.sh", "db:3306", "-t", "3600", "--", "execute", "api"] #waiting very long enough to set the db server up and running
image: <my registry's url>/api:latest
ports:
- "80:80"
restart: always
volumes:
mysql:
driver: azure_file
driver_opts:
share_name: Azure_Share_Name
storage_account_name: Azure_Storage_Account_Name
storageaccountkey: Azure_Key
【问题讨论】:
-
关于这个问题的任何更新?它解决了你的问题吗?如果它适合你,请接受它。
标签: azure azure-web-app-service azure-storage azure-files azure-storage-files