Django with Docker stuck on "Watching for file changes with StatReloader"

Viewed 5215

This is my code

https://imgur.com/A49j4Dd

When I run "python manage.py runserver 0.0.0.0:8000" it works perfectly fine.

https://imgur.com/4wc9dgQ

But when I use docker with "make compose-start" it doesnt work.

https://imgur.com/fiujufu

Im trying to follow a python tutorial and cannot progress without fixing this. It just hangs there.

What do I do? Is something wrong? Anything else I could screenshot to help?

EDIT: Apparently the server is up and running as it hangs there at "Watching for file changes with StatReloader". The website runs. However its supposed to look like this in the terminal,

https://imgur.com/Gue6y31

Is this a non-issue and theres nothing wrong?

4 Answers

try adding tty: true to your docker-compose.

services:
  web:
    tty: true

I had the same issue and solved it by adding this line to the Dockerfile:

ENV PYTHONUNBUFFERED=1

like the Django example on docker doc

I had the same problem using latest python solved it for me

only change I made was

FROM python:3

to

FROM python

my full Dockerfile looks like this

FROM python
COPY . .
EXPOSE 8000
RUN pip install -r requirements.txt
CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]

Add this to your Dockerfile:

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
Related