I am running a python app within a docker container, that apps seems to be running properly, However when I reach the point where the app write to a file inside container (/app/data/somefile.txt, which is mapped to a volume on my host machine) I get an error which basically states that I dont have permission to write.
Exception has occurred: PermissionError
[Errno 13] Permission denied: ‘/modbus-client-influxdb/data/version.txt’
How can i write this file and then perisist the data on torizon host.
Hi @fahads !
One thing that you could try is to manually launch the container and manually try to write to the same path/place.
Could you try to do that and share the result?
If you get into the desired folder, what is the output of
What is the output of
id from within the container?
Please also share your Dockerfile (and Docker compose, if existent).
I am inside the container and trying to create a file in
data folder inside my app’s directory
I still get the same error.
it seems that the container doesnt have correct permissions for writing to the directory.
Is there a way to allow these permissions?
The output of id command is below
I am creating the
data folder with python so it should have the same permissions as
main.py it seems that somehow the created folder requires
Hello @fahads ,
Who is the owner and what are the permissions of the folder in your machine? (not in the container)
Hi, the owner should be torizon not root.
Hello @fahads ,
So if I understand correctly, changing the owner of your folder from root to torizon solved your problem, is that correct?
yes but any file/directory i create inside container using python gets created as root by default
I used a volume mount inside the app which I think already has a bind mount. so the app you create on the host pc already has a bind mount on your board. creating a named volume creates a directory on host with root permissions so my python app was not able to access it due to less permissions. removed the volume mount and it started working.
maybe volumes shouldnt be root by default??