patterndockerMinor
docker volumes on cifs share cause permission disaster
Viewed 0 times
disastervolumesdockerpermissionsharecausecifs
Problem
I have a small vm running docker it only has a 20gig SSD which is more than enough for the OS + SWAP + Docker and the container images. But now I want to run a nextcloud docker image on that host. Because of the lack of space I mounted a cifs share to /data and started docker linking nextclouds data directory to the share.
The files are created but then docker tries to change the ownership of the files to www-data which does not work because the user www-data does not exist on the target system (the SMB Server). Which fails and terminates the docker instance.
There is no way to create the user www-data on the target system. Is there any way to get around this?
docker run -v /data/docker-volumes/nextcloud/data/:/var/www/html/ -p 8080:80 nextcloudThe files are created but then docker tries to change the ownership of the files to www-data which does not work because the user www-data does not exist on the target system (the SMB Server). Which fails and terminates the docker instance.
rsync: chown "/var/www/html/data" failed: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]There is no way to create the user www-data on the target system. Is there any way to get around this?
Solution
The problem can be solved by using mount options that force the application of the correct user and group eventhough these attributes can't really be set on the target system its sufficient to get around the docker related problem.
Also a reasonable set of privileges needs to be defined that is used for new files and folders.
Also a reasonable set of privileges needs to be defined that is used for new files and folders.
mount -t cifs -o username=user,password=pass, \ # provide creds
uid=www-data,forceuid,gid=root,forcegid, \ # force gid and uid
file_mode=744,dir_mode=744 //host/share /local/mountpoint # set permissions for new files and directoriesCode Snippets
mount -t cifs -o username=user,password=pass, \ # provide creds
uid=www-data,forceuid,gid=root,forcegid, \ # force gid and uid
file_mode=744,dir_mode=744 //host/share /local/mountpoint # set permissions for new files and directoriesContext
StackExchange DevOps Q#4424, answer score: 4
Revisions (0)
No revisions yet.