18👍
In your dockerfile
, you are pointing to a new user dockuser
.
RUN adduser -D dockuser
USER dockuser
Hence your container will start with user dockuser
which does not seem to have proper permissions to run /manage.py
.
You can either
- remove the above mentioned lines where you create and point to
dockuser
.
OR
- provide appropriate permissions to user
dockuser
usingchown
andchmod
commands in your dockerfile for /manage.py file.
I have answered such similar question here.
73👍
ubuntu 21.04
I got here searching for PermissionError: [Errno 13] Permission denied:
so i’ll just leave this here.
note: the below answer doesn’t work for multi user systems … see this answer instead for another possible solution
If you want to set it and forget it for 1 user, your own user … here’s what I have on my dev machine.
I didn’t own the unix socket, so I chowned it. ( this got it working straight away )
sudo chown $(whoami):$(whoami) /var/run/docker.sock
Another, more permanent solution for your dev environment, is to modify the user ownership of the unix socket creation. This will give your user the ownership, so it’ll stick between restarts:
sudo nano /etc/systemd/system/sockets.target.wants/docker.socket
docker.socket:
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=YOUR_USERNAME_HERE
SocketGroup=docker
[Install]
WantedBy=sockets.target
Again another less hacky solution: https://stackoverflow.com/a/70124863/2026508
NOTE for WSL ( NevilleLusimba )
might also want to change directory/app ownership to docker
$ sudo chgrp -R docker /path/to/directory
and give read and write access to docker
$sudo chmod -R g+rw /path/to/directory
Worked for me on Ubuntu 22.04 LTS via WSL
- [Django]-How do I use Django's MultiWidget?
- [Django]-Sorting related items in a Django template
- [Django]-Django: show the count of related objects in admin list_display
13👍
I had the same issue and solved it by adding my user to the docker
group:
$ sudo usermod -aG docker $(whoami)
- [Django]-Django: what is the difference (rel & field)
- [Django]-Django: How to set a field to NULL?
- [Django]-Django get the static files URL in view
6👍
add this to your Dockerfile
after RUN adduser -D dockuser
:
RUN chown dockuser:dockuser -R /app/
and why you COPY
the files if you already mount them ?
if you want to keep the mount , you need to add rw
persmission on the folder on the HOST
system not on the Container
- [Django]-Multiple annotate Sum terms yields inflated answer
- [Django]-Programmatically create a django group with permissions
- [Django]-Pytest.mark.parametrize with django.test.SimpleTestCase
4👍
If you’re on mac this might work for you.
After 4 days of troubleshooting this error (and other strange errors) I found out that I needed to fix dockers permissions in my file system. To do this go to:
System Preferences -> Security & Privacy -> Privacy tab -> Full Disk Access (on the left, somewhere in the list) -> Click on the + -> Docker application
Terribly frustrating problem to debug, hope it helps.
- [Django]-How to use "select_for_update()" to get an object in Django?
- [Django]-Using Django Rest Framework, how can I upload a file AND send a JSON payload?
- [Django]-Django: Validate file type of uploaded file
1👍
The Dockerfile that I was using was in the shared directory of my virtual machine (VirtualBox). Therefore, my issue was related to the default permission of this directory (UID=root, GID=vboxdf). I had to change it to my current user to properly run my container.
See https://superuser.com/a/640028/1655184 for a description on how to change the owner.
- [Django]-ImportError: Failed to import test module:
- [Django]-Django is "unable to open database file"
- [Django]-Dynamic choices field in Django Models
0👍
For me it was a WSL2 / Docker-Desktop setup issue on Windows.
What was missing was to explicitly enable the WSL distro: Docker Desktp Settings > Resources > WSL Integration > enable your distro
Then re-open WSL shell.
Before I could not even do docker run hello-world
but also had a very similar error message as the OP when running docker-compose.
- [Django]-Django Model Fields Indexing
- [Django]-Django 1.11 Annotating a Subquery Aggregate
- [Django]-Cancel an already executing task with Celery?
0👍
adding path to app like ‘/home/user/app:/app’ in docker-compose instead of just ‘.:/app’ resolved my problem
- [Django]-Rendering a template variable as HTML
- [Django]-How do you set DEBUG to True when running a Django test?
- [Django]-How to display all model fields with ModelSerializer?
0👍
For ubuntu, just add sudo to your command and run as root to get the permissions.
sudo docker-compose run app sh -c "django-admin startproject app ."
- [Django]-Login Page by using django forms
- [Django]-Django : DRF Token based Authentication VS JSON Web Token
- [Django]-Django URLS, how to map root to app?
0👍
I experienced similar issue, the problem was I running docker-desktop. The solution was to exit docker-desktop.
Os: Ubuntu 20.04LTS
rebuild and re-run command after exiting.
- [Django]-Macros in django templates
- [Django]-How do I change the range of the x-axis with datetime?
- [Django]-Django download a file