Marcos Mussio
Marcos Mussio

Reputation: 81

Docker permission error when using host user

I have a dockerfile installing a FastApi web service, using a custom user for accessing the /app folder, which is the folder that contains the web server.

I'm able to build the container, but I want to run it using the host user, since I want to preserve the permissions I have in some of the folder on the host(this is mandatory).

The problem is that the web service has a Logger class that persist a file.log on the container, but I'm getting a permission error(13) since I am assuming the host user does not have permissions to persist on the container within /home/developer/.logs

Dockerfile

RUN useradd -m developer
RUN chown -R developer:developer /app
RUN chmod 777 /home/developer && setfacl -d -m u::rwx,g::rwx,o::rwx /home/developer 
USER developer
WORKDIR /app

Docker Run docker run -it -u $(id -u):$(id -g) --name container_name image -v mounting_some_volumes

Error

PermissionError: [Errno 13] Permission denied: '/.logs'

I gave 777 permissions to the folder containing the logs and even I tried to mount that folder as a volume.

Any idea on how I can run the container using host user without getting errors?

Thanks,

Upvotes: 0

Views: 46

Answers (0)

Related Questions