K8S container loading Windows file sharing directory, solutions Permission denied access appear

K8S Pod, Docker container loading Windows host directory, issue Premission denied access to the appropriate file access occurs

Windows remote shared directory for //192.168.61.115/huashu
Windows user name and password are huashu huashu123
be mounted folder has been created, for the / mnt / data / remote / huashu


问题原因及解决办法:
   原因是CentOS7中的安全模块selinux把权限禁掉了,至少有以下三种方式解决挂载的目录没有权限的问题:
   1.在运行容器的时候,给容器加特权,及加上 --privileged=true 参数:
   docker run -i -t -v /mnt/data/remote/huashu:/mnt/data/remote/huashu --privileged=true arcvideo-cluster /bin/bash

   K8S Pod增加参数:
 
      containers:
      - image: qce-reg.cloudappl.com/zmpt/arcvideocluster:v258646_2.6.0.10
        securityContext:
          privileged: true


运行容器加上参数 privileged=true
使用该参数,container内的root拥有真正的root权限。
否则,container内的root只是外部的一个普通用户权限。
privileged启动的容器,可以看到很多host上的设备,并且可以执行mount。
甚至允许你在docker容器中启动docker容器。
   
   2.临时关闭selinux:
   setenforce 0
   3.添加selinux规则,改变要挂载的目录的安全性文本

mount -t cifs -o username=huashu,password=huashu123 //192.168.61.115/huashu  /mnt/data/remote/huashu

Guess you like

Origin www.cnblogs.com/shunzi115/p/12375406.html