title: Docker containers - DNS issue
body: <p>I have problem running any command requiring internet connection within my Dockerfile script (like calling <code>apt-get install xyz</code>), probably due to DNS problems.</p>
  
  <p>I've already read <a href="https://stackoverflow.com/questions/24832972/docker-apt-get-update-fails">this</a> thread and added <code>--dns 8.8.8.8 --dns 8.8.4.4</code> to <code>DOCKER_OPTS</code>. Unfortunately, it didn't help at all, still having issues connecting.</p>
  
  <p><strong>The only solution</strong> that works so far is to add the following line to my Dockerfile:</p>
  
  <pre><code>RUN 'echo nameserver 8.8.8.8 &gt; /etc/resolv.conf'
  </code></pre>
  
  <p>It works, but it's cluttering the Dockerfile a little bit. 
  I also tried to edit <code>/etc/resolv.conf</code> on my main machine, but it didn't help.</p>
  
  <p>Any suggestions? I'm running Ubuntu 14.04, kernel 3.13.0-35</p>
  
  <p><strong>// edit:</strong></p>
  
  <p>Here's the gradle script to generate Dockerfile:</p>
  
  <pre><code>task createDockerfile(type: Dockerfile) {
      dependsOn build
      destFile = project.file('build/Dockerfile')
      from 'java:8'
      volume '/tmp'
      runCommand 'echo nameserver 8.8.8.8 &gt; /etc/resolv.conf'
      runCommand 'apt-get update'
      runCommand 'apt-get install -y rabbitmq-server'
      runCommand 'service rabbitmq-server start'
      addFile 'libs/notification-bc-*.jar', 'notification-bc.jar'
      runCommand 'bash -c "touch /notification-bc.jar"'
      entryPoint 'java', '-jar', '/notification-bc.jar'
  }
  </code></pre>
  
  <p>and the resulting Dockerfile iteslf:</p>
  
  <pre><code>FROM java:8
  VOLUME ["/tmp"]
  RUN echo nameserver 8.8.8.8 &gt; /etc/resolv.conf
  RUN apt-get update
  RUN apt-get install -y rabbitmq-server
  RUN service rabbitmq-server start
  ADD libs/notification-bc-*.jar notification-bc.jar
  RUN bash -c "touch /notification-bc.jar"
  ENTRYPOINT ["java", "-jar", "/notification-bc.jar"]
  </code></pre>