I have a django app based on django-cookiecutter running on an aws-ec2.
The application itself built and is running ok. This application uses the django-cities-light library.
When I run docker-compose -f production.yml run --rm django python manage.py cities_light
which is the command to populate the database with countries/cities I get this error:
INFO 2021-11-30 15:17:36,780 cities_light 1 140562076800832 Creating /usr/local/lib/python3.9/site-packages/cities_light/data
Traceback (most recent call last):
File "/app/manage.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/cities_light/management/commands/cities_light.py", line 145, in handle
os.mkdir(DATA_DIR)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.9/site-packages/cities_light/data'
ERROR: 1
As '/usr/local/lib/python3.9/site-packages/cities_light/data' is inside the docker I am very confused regarding what permissions I should set and to whom.
If anyone could shed some light it will be much appreciated.
Thank you!
CodePudding user response:
Make sure the user inside the container has sufficient permission to '/usr/local/lib/python3.9/site-packages/cities_light/data'
.
If you have a non-root user inside the container, make sure this user owns/has access to the folder. Also take a look into this
CodePudding user response:
Thanks Vinoth for the suggestions. They were helpful.
I did a bit of reading and changing the ownership of the folder to django (user:group) by adding
RUN chown -R django:django /usr/local/lib/python3.9/site-packages/*
to docker file fixed the problem.