Goal: You want two Docker containers to use the same file share on the Docker server from time to time.
Problem/Error blocking goal: In a Docker container, when you try to change directories to a directory that is on the Docker host (e.g., the docker container was created with the --volume flag), and you get an error "bash: cd <directoryname> permission denied," you have to run two commands to fix it. An alternative problem is that you can cd into the directory, but when you try to list the files, you get "cannot open directory: Permission denied." The same solution applies.
Solution: From the Docker server, run these commands:
su -c "setenforce 0"
chcon -Rt svirt_sandbox_file_t </path/to/directoryname>
#where </path/to/directoryname> is the full path of the directory and its name
If you are running CentOS/RHEL/Fedora, you can avoid this problem after a reboot by doing the following on the Docker server itself:
1) Create /etc/profile.d/custom.sh
2) Provide these three lines as its contents:
#!/bin/bash
su -c "setenforce 0"
chcon -Rt svirt_sandbox_file_t </path/to/directoryname>
#where </path/to/directoryname> is the full path of the directory and its name