title: Use Docker --net=host and connect to other containers by hostname
body: <p>I would like to setup an Nginx reverse proxy, which works fine, but if I set <code>network_mode: "host"</code> it stops working because it is unable to find the hostname of other docker containers. I have a <code>web</code> container and an <code>nginx</code> container.</p>
  
  <p>I get the following error:
  <code>reverseproxy_1  | nginx: [emerg] host not found in upstream "web:80" in /etc/nginx/nginx.conf:10</code></p>
  
  <p>My Nginx conf file is:</p>
  
  <pre><code>worker_processes 1;
  
  events { worker_connections 1024; }
  
  http {
  
      sendfile on;
  
      upstream docker-web {
          server web:80;
      }
  
      server {
          listen 8080;
  
          location / {
              proxy_pass         http://docker-web;
              proxy_redirect     off;
              proxy_set_header   Host $host;
              proxy_set_header   X-Real-IP $remote_addr;
              proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header   X-Forwarded-Host $server_name;
          }
      }
    }
  </code></pre>
  
  <p>and my docker-compose.yml file is:</p>
  
  <pre><code>version: '2'
  services:
    redis:
      image: "redis:alpine"
    web:
      depends_on:
        - redis
      build: .\app
      volumes:
        - .\app:/code
      restart: always
    reverseproxy:
      image: reverseproxy
      network_mode: "host"
      ports:
        - 8080:8080
      depends_on:
        - web
  </code></pre>
  
  <p>I need to set network_mode to host else the the <code>X-Forwarded-For</code> will wrong.</p>