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
{{{#!bash
FROM ubuntu:14.04
MAINTAINER Chris Huang-Leaver <zeon...@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:
{{{#!bash
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 )
{{{#!bash
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;
{{{#!bash
mkdir whatever; cd whatever
echo 'Hello !' > index.html
python -m http.server
}}}
From the host;
{{{#!bash
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/24433>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
New description:
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:
{{{#!bash
Using the following Dockerfile
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24433#comment:1>
Old description:
> 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:
> {{{#!bash
New description:
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:
{{{#!bash
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
{{{#!bash
FROM ubuntu:14.04
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24433#comment:2>
* status: new => closed
* resolution: => needsinfo
Comment:
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?
--
Ticket URL: <https://code.djangoproject.com/ticket/24433#comment:3>
* type: Bug => Uncategorized
Comment:
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/24433#comment:4>
* resolution: needsinfo => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/24433#comment:5>