Issue
I'm having a permissions issue when trying to run my docker-compose command
docker-compose run app sh -c "django-admin.py startproject app ."
ERROR:
PermissionError: [Errno 13] Permission denied: '/app/manage.py'
I've done some research and found a similar issue here: docker-compose , PermissionError: [Errno 13] Permission denied: '/manage.py'
However I think I'm doing something wrong when trying to change permissions in my Dockerfile
Dockerfile:
FROM python:3.8-alpine
MAINTAINER Nick
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
RUN chown user:user -R /app/
RUN chmod +x /app
USER user
I add RUN chown user:user -R /app/
and RUN chmod +x /app
running docker build .
works succesfully however I still keep getting permissions issue
docker-compose.yml
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app /app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
Solution
For whatever reason changing my
docker-compose.yml from
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app /app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
To
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
I modified - ./app /app
to - ./app:/app
. It fixed the issue. If anyone has an explanation that would be great.
Thanks for the help.
Answered By - Nick Answer Checked By - Marilyn (WPSolving Volunteer)