问题描述
我正在尝试建立一个通过文件共享到存储帐户具有持久性存储的Web应用.
I'm trying to set up a web app that has persistent storage via file share to a storage account.
我正在遵循Microsoft文档中的各种指南,而我设法做到了大部分,我的应用程序具有持久存储能力.但是现在,我想做的是,我想将卷映射到我的存储帐户.
I'm following various guides from Microsoft docs and I managed to do most of it, my app has persisted storage. But now, what I wanna do, I want to map volumes to my storage account.
我看到有一个可以在docker-compose中使用的变量 $ {WEBAPP_STORAGE_HOME}
.
I saw that there is this variable ${WEBAPP_STORAGE_HOME}
that I can use in my docker-compose.
我的问题是,此变量的值是多少?文档状态:
My question is, what is the value of this variable? The docs state:
我觉得这有点模糊.它知道自动映射我的路径映射吗?如果我有多个路径映射该怎么办?是否应该在 Configuration
刀片中的应用程序设置"中设置值?如果是这样,我需要指定什么安装路径?
I find this a little vague. Does it know automatically to map my path mappings? What if I have multiple path mappings? Should I set the value in the App Settings in the Configuration
blade? If so, what do I need to specify, the mount path?
除此之外,我看到它的用法如下:
Besides that, I saw that it is used as following:
version: '3.3'
services:
wordpress:
image: mcr.microsoft.com/azuredocs/multicontainerwordpress
volumes:
- ${WEBAPP_STORAGE_HOME}/site/wwwroot:/var/www/html
ports:
- "8000:80"
restart: always
我在docker-compose中使用了命名卷.我认为没有必要指定类似的内容吗?
I'm used with named volumes in docker-compose. I figure there is no need to specify something like that?
更新在@Jason Pan回答之后,我尝试了一下坐骑.
UPDATEAfter @Jason Pan's answer, I tried to play with the mount a little bit.
我成功通过以下docker-compose在App Service上进行了持久存储:
I succeeded in having persisted storage on the App Service with the following docker-compose:
# ... lines skipped for brevity
volumes:
- mysql-data:/var/lib/mysql
volumes:
mysql-data:
driver: local
但是我想将数据保留在存储帐户中.我看到可以通过以下方式实现: AppService/Configuration/Path Mappings
.
But I want to persist the data on a Storage Account. I saw that this is possible via: AppService/Configuration/Path Mappings
.
我的Docker Compose
My Docker Compose
# ...
volumes:
- MyMountedPath:/var/lib/mysql
在这个docker-compose文件中,我有我的应用和一个MySQL映像:确切地说,是 mysql:8
.
In this docker-compose file, I have my app and a MySQL image: mysql:8
to be exact.
我安装了一条路径,如下所示:名称:MyMountedPath;挂载路径:/usr/local/mysql;类型:Azure文件...
.
I mounted a path as follows:Name: MyMountedPath; Mounted Path: /usr/local/mysql; Type: Azure Files ...
.
我在日志中收到以下错误:
And I get the following error in the logs:
由于它可以与第一种方法一起使用,因此我怀疑路径映射的定义方式存在一些问题.这使我提出了更多问题:
Since it worked with the first approach, I suspect that there are some issues with the way my Path mapping is defined. This led me to even more questions:
- 我的挂载路径是否需要存在于App Service文件系统上?如果没有,我可以定义以下内容:
/foo/bar
吗? - 如果我的挂载路径名为
MyMountedPath
,我可以在docker-compose文件中指定类似的内容 吗?
- Does my Mount Path need to exist on the App Service File system? If no, can I define something like:
/foo/bar
? - If I have a Mount Path name
MyMountedPath
, can I specify in the docker-compose file something like
volumes:
- MyMountedPath/foo:/something
基本上是在安装的路径中导航吗?
Basically, navigating in the mounted path?
- 是否需要在存储帐户的文件存储中挂载此路径?还是在需要存储内容时App Service会创建此路径?
推荐答案
感谢TeddyDubois29的回答,希望它也能为您提供帮助.
Thanks for TeddyDubois29's answer, hope it also can help you.
这篇关于docker-compose中WEBAPP_STORAGE_HOME变量的Azure Web App使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!