title: Docker run results in "host not found in upstream" error
body: <p>I have a frontend-only web application hosted in Docker. The backend already exists but it has "custom IP" address, so I had to update my local /etc/hosts file to access it. So, from my local machine I am able to access the backend API without problem.</p>
  
  <p>But the problem is that Docker somehow can not resolve this "custom IP", even when the host in written in the container (image?) /etc/hosts file.</p>
  
  <p>When the Docker container starts up I see this error </p>
  
  <pre><code>$ docker run media-saturn:dev
  2016/05/11 07:26:46 [emerg] 1#1: host not found in upstream "my-server-address.com" in /etc/nginx/sites/ms.dev.my-company.com:36
  nginx: [emerg] host not found in upstream "my-server-address.com" in /etc/nginx/sites/ms.dev.my-company.com:36
  </code></pre>
  
  <p>I update the /etc/hosts file via command in Dockerfile, like this</p>
  
  <pre><code># install wget
  RUN  apt-get update \
    &amp;&amp; apt-get install -y wget \
    &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  # The trick is to add the hostname on the same line as you use it, otherwise the hosts file will get reset, since every RUN command starts a new intermediate container
  # it has to be https otherwise authentification is required
  RUN echo "123.45.123.45 my-server-address.com" &gt;&gt; /etc/hosts &amp;&amp; wget https://my-server-address.com 
  </code></pre>
  
  <p>When I ssh into the machine to check the current content of /etc/hosts, the line "123.45.123.45 my-server-address.com" is indeed there.</p>
  
  <p>Can anyone help me out with this? I am Docker newbee.</p>