If I wanted a Docker container to have access to a local SMB share I needed it to be mounted every time the server was restarted. I found that doing the following steps allowed me to do so.
sudo apt install cifs-utils
sudo mkdir /media/share
sudo chown 1000:1000 /media/share
sudo chown 1000:1000 /media
sudo nano ~/.smbcredentials
In the .smbcredentials
file put in the username and password you want to use to access the SMB share. Then press Ctrl+X, Y, and Enter to save and exit.
username=smb-username
password=smb-password
sudo nano /etc/fstab
You’ll want to be careful in this step. Right after the last line enter the following and replace the highlighted text. Don’t change anything else! Then press Ctrl+X
, Y
, and Enter
to save and exit.
//server-ip/share-location /media/share cifs vers=3.0,uid=1000,gid=1000,credentials=/home/server-username/.smbcredentials
You can test to see if your share mounted by doing the following.
sudo mount -a
cd /media/share
ls
You should see the folders or files of the share-location
.