I want to run Django in a simple Docker container.
First I built my container with Docker-file. There wasn\'t anything special in it (only FROM, RUN and COPY commands)>
The problem is that you're exposing the development server to 127.0.0.1
inside your Docker container, not on the host OS.
If you access another console to your container and do a http request to 127.0.0.1:8000
it will work.
The key is to make sure the Docker container exposes the development server to all IPv4 addresses, you can do this by using 0.0.0.0
instead of 127.0.0.1
.
Try running the following command to start your Django development server instead:
python manage.py runserver 0.0.0.0:8000
Also, for further inspiration, you can check out this working Dockerfile for hosting a Django application with the built-in development server https://github.com/Niklas9/django-unixdatetimefield/blob/master/Dockerfile.