Search code examples
azuredockerpermissionsazure-storageazure-container-service

How to mount docker container home directory to Azure Storage


I am new to docker. I'm trying to get atmoz/sftp container work with Azure Storage.

My goal is to have multiple SFTP users who will upload files to their own folders which I can then find on Azure Storage.

I used the following command:

az container create \
--resource-group test \
--name testsftpcontainer \
--image atmoz/sftp \
--dns-name-label testsftpcontainer \
--ports 22 \
--location "East US" \
--environment-variables SFTP_USERS="ftpuser1:yyyy:::incoming ftpuser2:xxx:::incoming" \
--azure-file-volume-share-name test-sftp-file-share \
--azure-file-volume-account-name storagetest \
--azure-file-volume-account-key "zzzzzz" \
--azure-file-volume-mount-path /home

The container is created and run but when I unsuccessfully try to connect via Filezilla I get this in log:

Accepted password for ftpuser2 from 10.240.xxx.xxx port 64982 ssh2 
bad ownership or modes for chroot directory component "/home/"

If I use /home/ftpuser1/incoming it works for one of the users.

Do I need to change permissions on the /home directory first? If so, how?


Solution

  • Of course, you can mount the Azure File Share to the container directory /home. And it works perfectly on my side:

    enter image description here enter image description here

    And I also make a test with the image atmoz/sftp. And it also works fine. The command here:

    az container create -g myResourceGroup \
    -n azuresftp \
    --image atmoz/sftp \
    --ports 22 \
    --ip-address Public \
    -l eastus \
    --environment-variables SFTP_USERS="ftpuser1:yyyy:::incoming ftpuser2:xxx:::incoming" \
    --azure-file-volume-share-name fileshare \
    --azure-file-volume-mount-path /home \
    --azure-file-volume-account-name xxxxxx \
    --azure-file-volume-account-key xxxxxx
    

    Here is the screenshot:

    enter image description here

    Update:

    With the requirements, the error shows the bad ownership and it's impossible to control the permissions when you mount the Azure file share to the path /home or /home/user right now. So I recommend you mount the Azure file share to the path /home/user/upload of every user and it will go to the same result as you need.