Docker-compose: using azure file share like bind mount with volumes

tewodros 1 Reputation point
2021-09-12T19:41:06.287+00:00

I have the below docker-compose.yml file where I am looking to use an azure file share with two specific paths on the share (share-data/nginx and share-data/config/nginx.conf) that should map to two locations in the container. When running docker compose up I am getting duplicate volume mount error. Why can't I use the below azure file share paths like one would with a bind mount?

version: '3.7'

services:

nginx:
  image: nginx
  volumes:
    - share-data/nginx:/opt/nginx
    - share-data/config/nginx.conf:/etc/nginx/nginx.conf 
  ports:
    - 80:80
    - 443:443

volumes:
  data:
    driver: azure_file
    driver_opts:
      share_name: share-data
      storage_account_name: storage-data
Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,156 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
633 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 13,921 Reputation points MVP
    2021-09-13T09:36:29.77+00:00

    Hi @tewodros

    • Azure file share volume mount requires the Linux container run as root

    Below is the sample YAML template to Deploy container and mount volume

    apiVersion: '2019-12-01'  
    location: eastus  
    name: file-share-demo  
    properties:  
      containers:  
      - name: hellofiles  
        properties:  
          environmentVariables: []  
          image: mcr.microsoft.com/azuredocs/aci-hellofiles  
          ports:  
          - port: 80  
          resources:  
            requests:  
              cpu: 1.0  
              memoryInGB: 1.5  
          volumeMounts:  
          - mountPath: /aci/logs/  
            name: filesharevolume  
      osType: Linux  
      restartPolicy: Always  
      ipAddress:  
        type: Public  
        ports:  
          - port: 80  
        dnsNameLabel: aci-demo  
      volumes:  
      - name: filesharevolume  
        azureFile:  
          sharename: acishare  
          storageAccountName: <Storage account name>  
          storageAccountKey: <Storage account key>  
    tags: {}  
    type: Microsoft.ContainerInstance/containerGroups  
    

    If the Answer is helpful, please click Accept Answer and up-vote, so that it can help others in the community looking for help on similar topics.


  2. akshay95 21 Reputation points
    2021-10-18T17:55:26.94+00:00

    Hello All,
    I have storage account set up with SMB file share and I am having similar issues.
    When I try this -

    version: '3'

    volumes:
    postgres-db-volume:
    azureFile:
    sharename: ##
    storageAccountName: ##
    storageAccountKey: ##

    I am getting an error as -
    volumes.azureFile value 'sharename', 'storageAccountKey', 'storageAccountName' do not match any of the regexes: '^x-'

    Is there any plugins/Docker Azure context I need to set up?