是否有人成功地将 Azure 文件共享路径映射与容器卷路径映射。我正在专门寻找在 azure 中安装 Allure Docker 容器并将容器卷路径映射到 Azurefile 共享路径。
我使用过 ARM 模板和 yml 文件。但我找不到在 Azure 在线文档中定义或解释的安装卷路径。
我还看到了一个选项,可以创建自己的容器并将其托管在 Azure 容器注册表中,然后他们可以使用 docker-compose 文件来映射卷路径。这不是我追求的。我不想在 ACR 中托管容器。我一直在使用第三方容器。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"containerGroups_tst_tf_allure_report_api_aci_name": {
"defaultValue": "tst-tf-allure-report-api-aci",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2019-12-01",
"name": "[parameters('containerGroups_tst_tf_allure_report_api_aci_name')]",
"location": "[resourceGroup().location]",
"properties": {
"sku": "Standard",
"containers": [
{
"name": "[parameters('containerGroups_tst_tf_allure_report_api_aci_name')]",
"properties": {
"image": "frankescobar/allure-docker-service",
"ports": [
{
"protocol": "TCP",
"port": 5050
}
],
"volumeMounts": [
{
"name": "filesharevolume",
"mountPath": "/mnt/acishare/projects"
}
],
"environmentVariables": [
{
"name": "CHECK_RESULTS_EVERY_SECONDS",
"value": 1
},
{
"name": "KEEP_HISTORY",
"value": 1
},
{
"name": "KEEP_HISTORY_LATEST",
"value": 25
}
],
"resources": {
"requests": {
"memoryInGB": 1,
"cpu": 1
}
}
}
}
],
"initContainers": [],
"restartPolicy": "OnFailure",
"osType": "Linux",
"ipAddress": {
"ports": [
{
"protocol": "TCP",
"port": 5050
}
],
"type": "Public"
},
"volumes": [
{
"name": "filesharevolume",
"azureFile": {
"shareName": "acishare",
"storageAccountName": "acistoragev1",
"storageAccountKey": "zzzxxxxxxxxxddddddddddddddd"
}
}
]
}
}
]
}
答案 0 :(得分:0)
我没有发现您的 ARM 模板有任何问题,而且在我这边工作正常。在容器上映射 Azure 文件共享时,您可以看到该路径中的文件。但需要注意的是,该路径必须是新的,否则映射前该路径中不存在任何文件。 Azure 文件共享将隐藏之前存在的文件。 Here 是将 Azure 文件共享映射到 ACI 的示例。
答案 1 :(得分:0)
好吧,在用 Azure 容器和 Fileshare 调试了很多之后,我终于得到了答案。 “mountPath”基本上是您要映射回 Azure Fileshare 目录的容器卷路径。但是该路径不需要存在于文件共享目录中。只是根名称 /acishare 应该与您的文件共享目录匹配。 在我上面的例子中,它是 /acishare/projects。修复此问题后,我可以看到卷正确地将文件复制到 /acishare/projects 目录,我可以重新启动容器或重新创建容器,文件被保留并重新同步回容器。