I would like to access a Windows file share share (SMB3) from a docker container, but I do not want to compromise the security of the host machine. All the guides I have read state that I need to use either the --privileged
flag or --cap-add SYS_ADMIN
capability.
Here is the command I use:
mount -t cifs -o username='some_account@mydomain.internal',password='some_password' //192.168.123.123/MyShare /mnt/myshare
Which results in the message:
Unable to apply new capability set.
When I apply the --cap-add SYS_ADMIN
capability the mount command works fine, but I understand this exposes the host to obvious security vulnerabilities.
I have also read the suggestion in this StackOverflow question (Mount SMB/CIFS share within a Docker container) to mount the volume locally on the server that runs docker. This is undesirable for two reasons, firstly, the container is orchestrated by a Rancher Kubernetes cluster and I don't know how to achieve what is described by nPcomp using Rancher, and two, this means the volume is accessible to the docker host. I'd prefer only the container have access to this share via the credentials given to it via secrets.
My question is: is there way to mount a CIFS/SMB3 share in a docker container (within Kubernetes) without exposing the host to privilege escalation vulnerabilities and protecting the credentials? Many thanks.