azure - 如何使用 docker-compose 将 Azure 文件共享挂载为容器组卷?

标签 azure docker docker-compose azure-storage azure-files

我想从我的 Docker-Compose 将 Azure 文件共享挂载为卷。我从 Microsoft 获得的示例是使用 Azure CLI 。我怎样才能实现同样的目标,但是使用docker-compose

以下 docker-compose 对我不起作用,因为我无法在 Windows 环境中安装 azure_file 驱动程序,该驱动程序也已被弃用。

docker-compose.yml

version: "3.7"

services:
  web:
    build: .
    image: flask-app
    container_name: flask-app
    ports:
      - "5000:5000"
    volumes:
      - code:/code
    depends_on:
      - redis
  redis:
    image: redis

volumes:
  code:
    driver: azure_file
    driver_opts:
      share_name: myacishare
      storage_account_name: mystorageaccount

Dockerfile

FROM python:3.8
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.py

app.py

from flask import Flask
from redis import Redis

app = Flask(__name__)
redis = Redis(host="redis", port=6379)


@app.route("/")
def hello():
    redis.incr("hits")
    return "This Compose/Flask demo has been viewed %s time(s)." % redis.get("hits")


if __name__ == "__main__":
    app.run(host="0.0.0.0", debug=True)

需求.txt

flask
redis

最佳答案

docker plugin install docker4x/cloudstor:azure-v17.03.0-ce --grant-all-permissions --alias azure CLOUD_PLATFORM=AZURE AZURE_STORAGE_ACCOUNT="[account name]" AZURE_STORAGE_ACCOUNT_KEY="[access key]"

此版本的cloudstor适合我,但您可以尝试https://registry.hub.docker.com/r/docker4x/cloudstor/tags中的其他选项

回答来自:https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-containers-volume-logging-drivers#using-your-own-volume-or-logging-driver

关于azure - 如何使用 docker-compose 将 Azure 文件共享挂载为容器组卷?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67374908/

相关文章:

azure - 如何使用 Mongo API 在共享吞吐量 cosmosdb 中创建集合

docker - 如何验证从 docker-compose 构建的 docker images 的有效性?

elasticsearch - Docker-ELK堆栈— “Elasticsearch appears to be uneachable or down”

Azure 私有(private) DNS 区域解析

c# - Microsoft.ApplicationInsights 错误 : InstrumentationKey cannot be empty

PowerShell 中的 Azure CLI 和 SAS token 问题

docker - fe_sendauth:创建数据库时未提供密码

windows - 如何在 Windows 10 docker 桌面中访问/var/lib/docker?

python - 我在端口 8000 :80, 上的 apache+docker 上运行 django 应用程序需要用另一个端口运行另一个应用程序但不工作

docker - 使用docker-compose进行构建时消除docker <none>镜像