简体   繁体   English

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

[英]How to mount Azure File Share as Volume for Container Group using docker-compose?

I want to mount Azure File Share as volume from my Docker-Compose.我想从我的 Docker-Compose 将 Azure 文件共享作为卷安装。 The example I have from Microsoft is to use Azure CLI .我从 Microsoft 获得的示例是使用Azure CLI How can I achieve the same, but with docker-compose ?我怎样才能达到同样的效果,但使用docker-compose

The following docker-compose does not work for me as I am unable to install azure_file driver in my Windows environment, which has also been deprecated.以下docker-compose对我不起作用,因为我无法在我的 Windows 环境中安装azure_file驱动程序,该环境也已被弃用。

docker-compose.yml 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 Dockerfile

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

app.py应用程序.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)

requirements.txt要求.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]"

this version of cloudstor works for me, but you can try other options from https://registry.hub.docker.com/r/docker4x/cloudstor/tags这个版本的cloudstor适用于我,但你可以尝试https://registry.hub.docker.com/r/docker4x/cloudstor/tags中的其他选项

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Azure(容器Web应用程序)上将卷(Azure文件共享)安装到基于Bitnami的Docker映像? - How to mount a volume (Azure File Share) to a bitnami-based docker image on Azure (Web App for Container)? 将 azure 文件共享安装到 web 应用程序,用于 docker-compose 的 linux 容器 - mount azure file share to web app for linux containers with docker-compose Azure 容器实例 - 如何通过 Azure 门户从 Azure 文件共享挂载卷? - Azure Container Instances - how to mount volume from Azure File Share through the Azure Portal? 如何使用 docker compose YAML 在 Azure 中挂载 docker 卷 - How to mount a docker volume in Azure with docker compose YAML 在 docker-compose 中挂载 azure 存储帐户 - Mount azure storage account in docker-compose 在Azure App Service中使用docker容器时装入卷 - Mount a volume while using a docker container in Azure App Service 无法使用 docker-compose 文件将 docker 映像推送到 Azure 注册表容器 - Unable to push docker images to Azure Registry Container using docker-compose file 流行的反应问题:如何使用 docker-compose 在 Azure 中运行为 reactjs 应用程序提供服务的 docker 容器? - POPULAR REACT ISSUE : How to run docker container serving a reactjs app in Azure using docker-compose? 如何将 Azure 文件共享映射为 Docker Compose 文件中的卷? - How do I map an Azure File Share as a volume in a Docker Compose file? 将现有的 azure 文件共享挂载为持久卷而不使用机密 - Mount existing azure file share as a persistent volume without using secret
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM