Solve the problem of Dokekr file mounting without execution permission in Centos7

The Docker file is mounted
in CentOS7 , and the container does not have execution permission . Run the NodeJs container in CentOS7. It is found that the mounted local directory does not have the execution permission in the container. After various verifications and Google searches, I found the cause of the problem. Do it here recording. The reason is that the security module selinux in CentOS7 has disabled permissions. There are at least the following three ways to solve the problem that the mounted directory does not have permissions:

1. When running the container, add privileges to the container:

示例:docker run -i -t --privileged=true -v /home/docs:/src waterchestnut/nodejs:0.12.0

2. Temporarily close selinux:

Example: su -c "setenforce 0"

Then execute: docker run -i -t -v /home/docs:/src waterchestnut/nodejs:0.12.0

Note: Remember to restart selinux afterwards, command: su -c "setenforce 1"

3. Add selinux rules and add the directory to be mounted to the whitelist:

Example: chcon -Rt svirt_sandbox_file_t /home/docs

Then execute: docker run -i -t -v /home/docs:/src waterchestnut/nodejs:0.12.0

Guess you like

Origin blog.csdn.net/D_J1224/article/details/107614147