title: Docker app server ip address 127.0.0.1 difference of 0.0.0.0 ip
body: <p>He everyone. I'm working with docker and trying to dockerize a simple django application that does an external http connect to a web page (real website)
  so when I set in the Docker file the address of my django server that should work in the container - <strong>127.0.0.1:8000</strong>. my app wasn't working because of the impossibility to do an external connection to the website.</p>
  
  <p>but when I set the port for my server: <strong>0.0.0.0:8000</strong> it started to work.</p>
  
  <p><strong>So my question is:</strong> Why it behaves like that? What is the difference in this particular case? I just want to understand it.</p>
  
  <p>I read some articles about 0.0.0.0 and it's like a 'generic' or 'placeholder' port that allows to use the OC default port.</p>
  
  <p>127.0.0.1 is like a host that redirects the request to the current machine. I knew it.
  But when I run the app at my localmachine (host: 127.0.0.0:8000) everything was working and the app could do the connection to the real website but in case of docker it stopped to work.</p>
  
  <p>Thanks for any help!</p>
  
  <p>Here are my sources:
  Docker file</p>
  
  <pre><code>FROM python:3.6
  
  RUN mkdir /code
  WORKDIR /code
  
  COPY requirements.txt ./
  RUN pip install --no-cache-dir -r requirements.txt
  
  COPY . ./
  
  EXPOSE 8000
  
  ENTRYPOINT [ "python", "manage.py" ]
  CMD [ "runserver", "127.0.0.1:8000" ] # doesn't work
  # CMD [ "runserver", "0.0.0.0:8000" ] - works
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: "3"
  services:
    url_rest:
      container_name: url_keys_rest
      build:
        context: .
        dockerfile: Dockerfile
      image: url_keys_rest_image
      stdin_open: true
      tty: true
      volumes:
        - .:/var/www/url_keys
      ports:
        - "8000:8000"
  </code></pre>
  
  <p>here is the http error that I received in case of 127.0.0.1. Maybe it will be useful.</p>
  
  <pre><code>http: error: ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /api/urls (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x10cd51e80&gt;: Failed to establish a new connection: [Errno 61] Connection refused')) while doing GET request to URL: http://127.0.0.1:8000/api/urls
  </code></pre>