Docker data volume permission example details
- 2020-05-27 07:42:39
Docker data volume permissions
When running the NodeJs container in CentOS7, it was found that the mounted local directory had no execution permission in the container. After various validations and Google searches, the cause of the problem was found. The reason is that the security module selinux in CentOS7 has disabled permissions. There are at least three ways to solve the problem of mounting directories without permissions:
1. When running the container, add privileges to the container:
Example: docker run-i-t --privileged= true-v /home/docs:/src waterchestnut/nodejs:0.12.0
2. Temporarily shut down 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 later, command: su-c "setenforce 1"
3, add the selinux rule, the directory to be mounted to the whitelist:
Example: chcon-Rt svirt_sandbox_file_t /home/docs
After that, docker run-i-t-v /home/docs:/src waterchestnut/nodejs:0.12.0
Thank you for reading, I hope to help you, thank you for your support of this site!