PermissionError: [Errno 13] Permission denied: '/code/'

I was trying to run django app on docker container. Followed steps mentioned at But after running the command docker-compose run web startproject composeexample . I facing error PermissionError: [Errno 13] Permission denied: ‘/code/’ I’m using centos 7. please help

[root@localhost docker-django]# docker-compose run web startproject composeexample .
Traceback (most recent call last):
File “/usr/local/bin/”, line 5, in
File “/usr/local/lib/python3.4/site-packages/django/core/management/”, line 338, in execute_from_command_line
File “/usr/local/lib/python3.4/site-packages/django/core/management/”, line 330, in execute
File “/usr/local/lib/python3.4/site-packages/django/core/management/”, line 393, in run_from_argv
self.execute(*args, **cmd_options)
File “/usr/local/lib/python3.4/site-packages/django/core/management/”, line 444, in execute
output = self.handle(*args, **options)
File “/usr/local/lib/python3.4/site-packages/django/core/management/commands/”, line 33, in handle
super(Command, self).handle(‘project’, project_name, target, **options)
File “/usr/local/lib/python3.4/site-packages/django/core/management/”, line 154, in handle
with open(new_path, ‘wb’) as new_file:
PermissionError: [Errno 13] Permission denied: ‘/code/’


Possibly this is because you have SELinux enabled on your CentOS 7. You can make this work in two ways.

  • Set SELinux to Disabled/Permissive mode. You can try setenforce 0 and try once again to make sure that SELinux is the one who is causing this problem.

  • Now if you don’t want to disable SELinux append a :Z to the volume declaration so that Docker will fix the SELinux context of the volume directory

Eg: docker run -d -v /myvol:/volmount:Z busybox

So in your case add :Z to the volume declaration in compose.yml.


Thanks a lot. It worked after adding :Z to volumes in yml file.