使用多个卷挂载设置 Azure 容器实例

使用多个卷挂载设置 Azure 容器实例

我正在尝试在 Azure 中设置一个 zookeeper 容器。我希望它使用三个不同的 Azure 文件共享。一个用于 zookeeper 配置,一个用于数据,一个用于日志。由于有多个挂载,我必须使用 ARM 模板进行部署。

此外,我不确定如何让容器使用 -v 开关,或者我是否需要这样做,以便它将我的配置共享视为所需的文件。您可以在命令覆盖中看到我的尝试。

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
    {
        "location": "centralus",
        "name": "redacted",
        "type": "Microsoft.ContainerInstance/containerGroups",
        "apiVersion": "2018-10-01",
        "properties": {
            "containers": [
                {
                    "name": "redacted",
                    "properties": {
                        "image": "zookeeper:latest",
                        "resources": {
                            "requests": {
                                "cpu": "1",
                                "memoryInGB": "1.5"
                            }
                        },
                        "ports": [
                            {
                                "port": "2181",
                                "protocol": "TCP"
                            }
                        ],
                        "command": [
                            "-v/azshare/config/zk/cfg:/conf/zoo.cfg zookeeper"
                        ],
                        "volumeMounts": [
                            {
                                "name": "config",
                                "mountPath": "azshare/config"
                            },
                            {
                                "name": "data",
                                "mountPath": "azshare/data"
                            },
                            {
                                "name": "logs",
                                "mountPath": "azshare/logs"
                            }
                        ]
                    }
                }
            ],
            "restartPolicy": "Always",
            "osType": "Linux",
            "ipAddress": {
                "type": "Public",
                "ports": [
                    {
                        "port": "2181",
                        "protocol": "TCP"
                    }
                ],
                "dnsNameLabel": "redacted"
            },
            "volumes": [
                {
                    "name": "config",
                    "azureFile": {
                        "shareName": "config",
                        "storageAccountName": "redacted",
                        "storageAccountKey": "redacted"
                    }
                },
                {
                    "name": "data",
                    "azureFile": {
                        "shareName": "data",
                        "storageAccountName": "redacted",
                        "storageAccountKey": "redacted"
                    }
                },
                {
                    "name": "logs",
                    "azureFile": {
                        "shareName": "logs",
                        "storageAccountName": "redacted",
                        "storageAccountKey": "redacted"
                    }
                }
            ]
        },
        "tags": {}
    }
]
}

答案1

事实证明,我的挂载路径需要以斜杠开头。路径应该是 /azshare/config 等。

就传递命令而言,看起来命令只是替换了 docker 入口点。如果您使用模板格式,则命令以空格分隔,因此每个空格都是一个新字符串。

相关内容