I have different services on the docker-compose
file that pulls some images to create containers on ACI.
Everything works fine on my local machine when I mount different directories and sub folders to docker containers:
volumes:
- folder/sub_folder/sub/folder:/etc/nginx/certs
But spinning up instances on ACI requires using azure_file
driver which I use but I am not able to mount subfolders from this fileshare to a path.
I created a volume in the compose file:
volumes:
data-volume:
driver: azure_file
driver_opts:
share_name: acishare
storage_account_name: storageaccount
storage_account_key: /run/secrets/storage_account_key.txt
and I have tried this for a container
services:
app:
volumes:
- data-volume:/etc/nginx/
The above works fine but mounts the home directory of the file share which is understandable since no directory was specified.
I did some research and saw that on AKS, one could specify the directory of the file as the share name. Tried this with the backward slash() but I got an error message saying the fileshare doesn’t exist:
volumes:
data-volume:
driver: azure_file
driver_opts:
share_name: acishare/sub_directory/sub_directory
storage_account_name: storageaccount
storage_account_key: /run/secrets/storage_account_key.txt
I have also tried adding the path to the volume but this won’t work too:
volumes:
- data-volume/sub_directory/sub_directory:/etc/nginx/
What is the correct way to mount different subfolders of Azure File Share to an ACI?
PS: My codebase is on github and I am using workflow to upload-batch
files to the azure file share because I need to copy (mount) a subfolder to the wwwroot directory in the container.
The repo also has some configuration files that need to be directly mounted to the container. These files are also not on the root folder but inside different subfolders.
If there is a better alternative to handle situations like this, I don’t mind. I have tried using blob storage but couldn’t come up with a way to go about it.
2
Answers
maybe you could try this:
Check the following link I hope it helps.
azure subdirs
Cheers!
I tried to reproduce but unable mount a single file/folder from Azure File Share to Azure Container Instance.
Deploy container and mount volume
.
Here one more thing notice whatever the files you will update in file share it will update in container as well after you mount the file share as volume to the container.
May this be the reason we can not mount specific file and folder as volume in container.
There are some limitations to this as well,
• You can only mount Azure Files shares to Linux containers. Review more about the differences in feature support for Linux and Windows container groups in the overview.
• You can only mount the whole share and not the subfolders within it.
• Azure file share volume mount requires the Linux container run as root.
• Azure File share volume mounts are limited to CIFS support.
• Share cannot be mounted as read-only.
• You can mount multiple volumes but not with Azure CLI and would have to use ARM templates instead.
Reference: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files
https://www.c-sharpcorner.com/article/mounting-azure-file-share-as-volumes-in-azure-containers-step-by-step-demo/