简体   繁体   English

如何将 Azure 文件共享映射为 Docker Compose 文件中的卷?

[英]How do I map an Azure File Share as a volume in a Docker Compose file?

I have so far only found examples on how to create a volume on the host machine, eg:到目前为止,我只找到了有关如何在主机上创建卷的示例,例如:

version: "3.3"
services:
  mysql:
    image: mysql
    volumes:
       - db-data:/var/lib/mysql/data
volumes:
  db-data:

So this defines a volume named db-data that will physically be stored on the host machine running the container.因此,这定义了一个名为 db-data 的卷,该卷将物理存储在运行容器的主机上。

Is is possible to makes the db-data volume point to an Azure File Share in an Azure Storage account and how would I specify the needed parameters?是否可以使 db-data 卷指向 Azure 存储帐户中的 Azure 文件共享,我将如何指定所需的参数?

From CLI you can create with:从 CLI 您可以创建:

docker volume create -d azurefile -o share=myvol --name vol1 

docker run -i -t -v vol1:/data busybox    

In your compose you need to use this skeleton:在您的撰写中,您需要使用此骨架:

volumes:
  myvol:
    driver: azurefile
    driver_opts:
      accountname: ___your__account_name
      accountkey: ___your_account_key
      share: "volumes"
      remotepath: "myvol"

UPDATE:更新:

These options are now deprecated, please follow instruction for CloudStor plugin at: https://docs.docker.com/docker-for-azure/persistent-data-volumes/这些选项现已弃用,请按照 CloudStor 插件的说明进行操作: https : //docs.docker.com/docker-for-azure/persistent-data-volumes/

The format that works for me currently is:目前对我有用的格式是:

version: "3.8"

volumes:
  db-data:
    driver: azure_file
    driver_opts:
      share_name: myfileshare
      storage_account_name: mystorageaccount

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

相关问题 如何使用 docker-compose 将 Azure 文件共享挂载为容器组的卷? - How to mount Azure File Share as Volume for Container Group using docker-compose? 如何在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)? 如何使用 Docker-compose 文件在 Azure WebApp 上部署 Grafana? - How I deploy Grafana on Azure WebApp with Docker-compose file? 如何从Azure文件共享下载文件结尾 - How do I download the end of a file from azure file share 如何使用 docker compose YAML 在 Azure 中挂载 docker 卷 - How to mount a docker volume in Azure with docker compose YAML Docker的Azure文件共享凭据 - Azure file share credentials for Docker 将 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? 在 Azure 上下文中将文件复制到 Docker 卷 - Copy file to Docker volume in Azure context 在 azure 上的 docker compose 文件上指定帐户凭据 - Specify account credentials on a docker compose file on azure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM