3๐
By default, Docker containers runs as root. This has two issues:
- In development as you can see, the files are owned by root, which is often not what you want.
- In production this is a security risk (https://pythonspeed.com/articles/root-capabilities-docker-security/).
For development purposes, docker run --user $(id -u) yourimage
or the Compose example given in the other answer will match the user to your host user.
For production, youโll want to create a user inside the image; see the page linked above for details.
2๐
Usually files created inside docker container are owned by the root user of the container.
You could try with this inside your container:
chown 1000:1000 file-you-want-to-edit-outside
You could add this as the last layer of your Dockerfile as RUN
Edit:
If you are using docker-compose
, you can add user
to your container:
service:
container:
user: ${CURRENT_HOST_USER}
And have CURRENT_HOST_USER
be equal to $(id -u):$(id -g)
๐คGeorgi Velev
0๐
The solution was to add
USER uwsgi_user
to Dockerfile
and then simpy run docker exec -it container-name sh
๐คMarek
- [Django]-When does the queryset use its _result_cache, not hitting the database?
- [Django]-Fresh python 3.7 / django 2.2.1 installation not recognising that mysqlclient is installed
Source:stackexchange.com