Reputation: 1561
I'm trying to start a Django app using Docker on Windows 10. I'm following the Quickstart Tutorial here:
https://docs.docker.com/compose/django/#connect-the-database
When it gets to the docker-compose up
part, to actually start the app, it gets stuck.
This is the docker-compose.yml:
version: '3'
services:
db:
image: postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
This is the Dockerfile:
FROM python:3.5
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
when I use docker-compose up
it gets stuck in:
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
Upvotes: 3
Views: 3153
Reputation: 11
I had the same issue but I found a workaround to run it.
In your Django settings.py change ALLOWED_HOST to
ALLOWED_HOST = ['*']
so Django will allow every host to access the app.
Finally, when you start your Docker Quickstart Terminal
it shows you default machine with IP 192.168.XX.XX
. Run docker-compose up
and you can find your Django app running on IP: 192.168.XX.XX:8000.
Don't worry docker-compose up
isn't stuck but it's just not echoing any Django output.
Upvotes: 0
Reputation: 11
I had the same issue and I found that it was caused by an error in a models.py
file.
After I stopped the server last time, I added one Model class (just forgot about it) without running the server. When I started the server the next time, I faced your problem, but searching the web was useless, because I had everything OK with my project settings (which often causes such errors).
Then I mentioned that I didn't apply migrations after the last change, so I ran the command:
docker-compose up web python3 manage.py makemigrations
docker-compose up web python3 manage.py migrate
and it showed me that there was an error in a new Model declaration. It caused the server to stop responding. I don't know why it works this way instead of showing an error message in a browser or console, but this is how it is. I fixed it and server began responding. I hope this will help someone.
Upvotes: 1
Reputation: 1561
For anyone coming across a similar issue, I solved it by running docker on the interface.
It was probably getting stuck because the DB was taking too long to start or something like that.
Upvotes: 0
Reputation: 578
I think I hit a similar issue. I found I needed to add the host ip to ALLOWED_HOSTS in composeexample/settings.py. For example
ALLOWED_HOSTS = [u'10.122.14.13']
Upvotes: 0