docker挂载centos
主机目录,访问相应的文件出现Cannot open: Permission denied
的权限访问问题。
[root@localhost software]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 1e1148e4cc2c 2 months ago 202 MB
[root@localhost software]# docker run -i -t -v /root/software/:/mnt/software/ 1e1148e4cc2c /bin/bash
[root@aba1f4fa9d9a /]# cd /mnt/software/
[root@aba1f4fa9d9a software]# ls
ls: cannot open directory .: Permission denied
[root@aba1f4fa9d9a software]#
网上查看原因是centos7
中的安全模块selinux
把权限禁掉了,解决办法很麻烦。通过查找资料,找到了一个简单的解决办法:挂载的时候加上--privileged=true
就可以了
[root@localhost software]# docker run -i -t -v /root/software/:/mnt/software/ --privileged=true 1e1148e4cc2c /bin/bash
[root@1a286fc4bdf6 /]# cd /mnt/software/
[root@1a286fc4bdf6 software]# ls
apache-tomcat-7.0.92.tar.gz
[root@1a286fc4bdf6 software]#