Search code examples
azuredockermount

`mount: permission denied` on Azure virtual machine running Docker


I created a Data Science Virtual Machine on Azure and a storage account (like I would a virtual machine). Then I followed these directions to create a file share. A blade "Connect" appears at the right with the command to connect from a Linux computer:

To connect to this file share from a Linux computer, run this command:

sudo mount -t cifs //storagename.file.core.windows.net/filesharename [mount point] -o vers=3.0,username=storagename,password=[GUID],dir_mode=0777,file_mode=0777,sec=ntlmssp

I start a Docker container with

sudo docker run -it tensorflow/tensorflow:latest-py3 bash

create a directory, replace [mount point] with it, and I get a permission error, and with sudo I get missing executable:

root@9cda7bc6176d:~# mkdir /mnt/storage
root@9cda7bc6176d:~# mount -t cifs //storagename.file.core.windows.net/filesharename /mnt/storage -o vers=3.0,username=storagename,password=[GUID],dir_mode=0777,file_mode=0777,sec=ntlmssp
mount: permission denied
root@9cda7bc6176d:~# sudo mount -t cifs //storagename.file.core.windows.net/filesharename /mnt/storage -o vers=3.0,username=storagename,password=[GUID],dir_mode=0777,file_mode=0777,sec=ntlmssp
bash: sudo: command not found

How can I mount an Azure file share inside a Docker container?


Solution

  • Do you need the file share to be on Azure? Because Docker can mount a filesystem and you don't have to manage an additional storage account. From this Stackoverflow thread, this command:

    sudo docker run -v ~:/mnt/caller -it tensorflow/tensorflow:latest-py3 bash
    

    will put you in a Docker container with the host home directory mounted at /mnt/caller.