Search code examples
azuredockerterraformazure-storagedocker-volume

Azure Docker Container volume pointing to a subdirectory/subfolder


On Azure I am provisioning a container group with multiple docker containers using Terraform. I would like to have each of the containers use a volume that's connected to the same file share, but at different subdirectories within that share.

file_share /directoryA /directoryB

I'm able to provision containerA with the volume-share_name = file_share.

I'd like to provision containerB with the volume-share_name = file_share/directoryA and containerC with the volume-share_name = file_share/directoryB

Is this possible and if so how do you specify it as the share_name in the Terraform code? If not is there a workaround?


Solution

  • I'm afraid it's impossible for you to do it. The Azure Container Instance currently does not support to mount the subdirectory of the file share to the instance. You just can mount the same file share with multiple containers to share the files in it.

    And if you want to mount the subdirectory of the file share, I recommend you use the AKS, it supports to do it. And when you use the AKS to do it, it would look like this:

      volumes:
      - name: volume1
        azureFile:
          secretName: azure-secret
          shareName: data/volume1
          readOnly: false
      - name: volume2
        azureFile:
          secretName: azure-secret
          shareName: data/volume2
          readOnly: false