It seems your Django project works well, I've tried to reproduce your error but I couldn't get it.
My directory tree:
.
|____app
| |____app
| | |____asgi.py
| | |______init__.py
| | |____settings.py
| | |____urls.py
| | |____wsgi.py
| |____manage.py
|____requirements.txt
|____Dockerfile
|____docker-compose.yml
requirements.txt
Django==3.1.5
Dockerfile:
FROM python:3.8-alpine
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
Docker-compose:
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app /app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
My steps:
- django-admin startproject app
- docker-compose build app
- docker-compose up
Output:
Creating django-3-1-5_app_1 ... done
Attaching to django-3-1-5_app_1
app_1 | Watching for file changes with StatReloader
app_1 | Performing system checks...
app_1 |
app_1 | System check identified no issues (0 silenced).
app_1 |
app_1 | You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
app_1 | Run 'python manage.py migrate' to apply them.
app_1 | January 06, 2021 - 21:03:42
app_1 | Django version 3.1.5, using settings 'app.settings'
app_1 | Starting development server at http://0.0.0.0:8000/
app_1 | Quit the server with CONTROL-C.
app_1 | [06/Jan/2021 21:03:52] "GET / HTTP/1.1" 200 16351
app_1 | [06/Jan/2021 21:03:52] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
app_1 | [06/Jan/2021 21:03:52] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
app_1 | [06/Jan/2021 21:03:52] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
app_1 | [06/Jan/2021 21:03:52] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184
app_1 | Not Found: /favicon.ico
app_1 | [06/Jan/2021 21:03:52] "GET /favicon.ico HTTP/1.1" 404 1969
^CGracefully stopping... (press Ctrl+C again to force)
Stopping django-3-1-5_app_1 ... done
Browser:
I'm thinking, you have another kind of perm issue, have you tried to build this image from a MacOS?
Try the following configuration:
System Preferences -> Security & Privacy -> Privacy tab -> Full Disk Access (on the left, somewhere in the list) -> Click on the + -> Docker application
I hope it may help you and other users.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…