Opened 10 years ago
Last modified 10 years ago
#24433 closed Uncategorized
Connection reset 'every time' when running inside Docker container — at Version 1
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 MAINTAINER Chris Huang-Leaver <zeonglow@gmail.com> 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.