I am trying to Mount the CIFS Share Drive(Azure Storage File Service) as root user, But still its not allowing to mount and throwing Error:
mount: permission denied (are you root?)
Please find the below Docker File and Entry Point File.
Docker File
FROM alpine:latest
USER root
RUN apk update \
&& apk add --no-cache ca-certificates wget
RUN apk add postgresql-client cifs-utils
COPY ./mount-drive.sh /tmp/mount-drive.sh
RUN chmod +X /tmp/mount-drive.sh
RUN apk --no-cache add sudo
ENTRYPOINT [ "sh", "/tmp/mount-drive.sh" ]
Entry Point File
mkdir /mnt/test
if [ ! -d "/etc/smbcredentials" ]; then
mkdir /etc/smbcredentials
fi
if [ ! -f "/etc/smbcredentials/<storageaccountname>.cred" ]; then
sh -c 'echo "username=<storageaccountname>" >> /etc/smbcredentials/<storageaccountname>.cred'
sh -c 'echo "password=PASSWORD" >> /etc/smbcredentials/<storageaccountname>.cred'
fi
chmod 600 /etc/smbcredentials/<storageaccountname>.cred
sh -c 'echo "//<storageaccountname>.file.core.windows.net/test /mnt/test cifs nofail,vers=3.0,credentials=/etc/smbcredentials/<storageaccountname>.cred,dir_mode=0777,file_mode=0777,serverino" >> /etc/fstab'
sudo -u root mount --t cifs //<storageaccountname>.file.core.windows.net/test /mnt/test -o vers=3.0,credentials=/etc/smbcredentials/<storageaccountname>.cred,dir_mode=0777,file_mode=0777,serverino