mongodbazureazure-container-instances

Unable to mount azure file shares as mongodb volume in azure container instances


I am trying to set up a mongo DB instance using azure container instances and mounting the same on Azure file share.

We are getting the following error:

[initandlisten] WiredTiger error (1) [1579245437:724939][1:0x7f9419c67b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1579245437:724939][1:0x7f9419c67b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
W  STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
F  STORAGE  [initandlisten] Reason: 1: Operation not permitted
F  -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 789
[initandlisten] 

***aborting after fassert() failure

AZ Commands I am using the following commands to create the storage account, file share, and container instance:

az storage account create -g $resourcegroup -n $storageaccount --sku Standard_LRS

az storage share create --name $mongofileshare --account-name $storageaccount

az container create --resource-group $resourcegroup --name $containername --image mongo:latest --dns-name-label $DNSName --ports 27017 --protocol TCP --environment-variables 'MONGO_INITDB_ROOT_USERNAME=admin' 'MONGO_INITDB_ROOT_PASSWORD=*******' --location westeurope --azure-file-volume-account-name $storageaccount --azure-file-volume-account-key '**********' --azure-file-volume-share-name 'mongofileshare' --azure-file-volume-mount-path '/data/db'

Solution

  • The reason that caused the error you got is that mount the Azure File Share to the container instance will cover all the files in the mount point. The caution is shown here:

    Mounting an Azure Files share to a container instance is similar to a Docker bind mount. Be aware that if you mount a share into a container directory in which files or directories exist, these files or directories are obscured by the mount and are not accessible while the container runs.

    So it's not recommended to mount the Azure File Share to the existing directory which contains the files used to initialize the Mongo DB. The recommend directory will like path /var/logs/.