简体   繁体   中英

Running 'docker-compose up' throws permission denied when trying official samaple of Docker

I am using Docker 1.13 community edition on a CentOS 7 x64 machine. When I was following a Docker Compose sample from Docker official tutorial , all things were OK until I added these lines to the docker-compose.yml file:

volumes:
 - .:/code

After adding it, I faced the following error: can't open file 'app.py': [Errno 13] Permission denied. It seems that the problem is due to a SELinux limit. Using this post I ran the following command:

su -c "setenforce 0"

to solve the problem temporarily, but running this command:

chcon -Rt svirt_sandbox_file_t /path/to/volume

couldn't help me.

Finally I found the correct rule to add to SELinux:

# ausearch -c 'python' --raw | audit2allow -M my-python
# semodule -i my-python.pp

I found it when I opened the SELinux Alert Browser and clicked on 'Details' button on the row related to this error. The more detailed information from SELinux:

SELinux is preventing /usr/local/bin/python3.4 from read access on the file app.py.

***** Plugin catchall (100. confidence) suggests **************************

If you believe that python3.4 should be allowed read access on the app.py file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing:

ausearch -c 'python' --raw | audit2allow -M my-python

semodule -i my-python.pp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM