question

tewodros-7837 avatar image
0 Votes"
tewodros-7837 asked learn2skills commented

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

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-filesazure-container-instances
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

To follow-up, Please let us know if you have further query on this.
Please don’t forget to Accept the answer

0 Votes 0 ·

1 Answer

learn2skills avatar image
0 Votes"
learn2skills answered

Hi @tewodros-7837

  • 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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.