amerkurev / django-docker-template

Dockerized Django with Postgres, Gunicorn, and Traefik or Caddy (with auto renew Let's Encrypt)
https://django-docker.dev
MIT License
169 stars 33 forks source link

Permission Issues When Running Docker Containers #9

Closed Hossein-Roshandel closed 8 months ago

Hossein-Roshandel commented 11 months ago

I encountered two permission issues while running containers with Docker on Fedora 38. Here are the details of the problems and the solutions I applied:

1- Issue with permission to access docker.sock

When I ran the following command:

docker compose -f docker-compose.debug.yml up

I encountered the following error:

"msg="Failed to retrieve information of the docker client and server host: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock"

To resolve this, I added privileged: true to the reverse-proxy YAML configuration in the docker-compose.debug.yml file.

2- Issue with permission to access source files in development container When I ran the following command:

docker run -it --rm -p 8000:8000 -v sqlite:/sqlite -v $(pwd)/website:/website django-docker-template:master python manage.py runserver 0.0.0.0:8000

I encountered the following error:

"python: can't open file '/usr/src/website/manage.py': [Errno 13] Permission denied"

To resolve this, I had to change /usr/src/website to /usr/src/website:z everywhere in the YAML files and the command.

Environment:

Hossein-Roshandel commented 8 months ago

I think the solution is in the description. I shall close it. Thanks