#24433 closed Uncategorized (invalid)
Connection reset 'every time' when running inside Docker container
Reported by: | zeonglow | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
This seems somewhat similar to #19022, but I get the issue with every request, not just randomly. So I think that ticket should have been 'cannot reproduce' rather than closed, hopefully this ticket will be more helpful.
As I discovered this whilst trying to run my Django app inside a Docker component, it should be easy for you to replicate. I can see this error with just the empty ' you haven't done any work yet' Django app, so we can rule out any problem with my application.
From my host machine:
django-admin startproject hellohello cd hellohello \ && ./manage.py migrate && ./manage.py
Django server starts up, I can see the welcome screen and all is well.
Using the following Dockerfile
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y python3-pip RUN pip3 install Django==1.7.5 RUN python3 -m compileall /usr/lib/python3* RUN ln -s /usr/bin/python3 /usr/bin/python
Build it:
sudo docker build -t my-django-python3 .
Run an interactive terminal from it. ( the bug is also present if you run the server directly, its just easier to see what is going on this way )
sudo docker run -t -i -p 9000:8000 --rm my-django-python3 /bin/bash
In the container, to prove that Docker networking is setup correctly;
mkdir whatever; cd whatever echo 'Hello !' > index.html python -m http.server
From the host;
curl http://localhost:9000/
which should return 'Hello!' as expected
return to the container, stop the python web server.
Repeat the, 'startproject, migrate, runserver' steps from the beginning of this ticket, only this time in the container.
From the host;
curl http://localhost:9000/
'Connection reset by peer'
There is no mention of the connection attempt in the Django server output, which stops normally when you ctrl+C it
I have tried this with a number of different configurations; using python 2 instead of 3, using the 'official' Django Docker images (which start with Debian not Ubuntu), Python images etc. the same result.
My host machine is also Ubuntu 14:04
#19022 Mentions high load as a possible cause, in my case, its just me hitting the server once with Curl.
This post on Stackoverflow http://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean may be helpful.
Change History (5)
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
comment:2 by , 10 years ago
Description: | modified (diff) |
---|
comment:3 by , 10 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:4 by , 10 years ago
Type: | Bug → Uncategorized |
---|
Hi Tim, yes you are correct, this in not a Django problem. I'l put the answer here because I'm sure it will help someone ;-)
If you run the following
python manage.py runserver
Django runs the development server on the localhost interface and port 8000, which is fine in most cases but with Docker, if you want to access 'anything' from outside a container it must listen on the faux eth0 interface, ( which is what the Docker documentation refers to as the 'bridge' interface)
In short
python manage.py runserver 0.0.0.0:8000
Works as expected.
The reverse example
python -m 'http.server' --bind localhost 8000
Serving HTTP on 127.0.0.1 port 8000 ...
Will now produce the 'connection resets' from outside the container.
comment:5 by , 10 years ago
Resolution: | needsinfo → invalid |
---|
Could you please ask for help via TicketClosingReasons/UseSupportChannels and reopen this ticket if the conclusions of that investigation points to a problem with Django?