title: Connection failed error when building docker image from ubuntu base image using Docker CE on macOS 10.13
body: <p>Im using Docker Community Edition v18.03 on my macOS 10.13 machine and have the following Dockerfile in my application.</p>
  
  <pre><code>FROM ubuntu:16.04
  ADD . /app
  WORKDIR /app
  RUN bin/setup
  </code></pre>
  
  <p>I build the image with</p>
  
  <pre><code>docker build -t myapp .
  </code></pre>
  
  <p>Now in the build process i see the following</p>
  
  <p><a href="https://i.stack.imgur.com/4BJ38.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4BJ38.png" alt="enter image description here"></a></p>
  
  <p>The file <code>bin/setup</code> installs the ruby package on ubuntu and is as follows</p>
  
  <pre><code>#!/bin/bash
  
  if ! which ruby &gt; /dev/null; then
    echo "Installing Ruby"
    apt-get -y update
    apt-get -y install linux-headers-$(uname -r) build-essential
    apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev
    apt-get clean
    apt-get -y install ruby-full
  fi
  </code></pre>
  
  <p>I tried adding dns settings as follows in Docker preferences but that didnt help</p>
  
  <p><a href="https://i.stack.imgur.com/cc7AC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cc7AC.png" alt="enter image description here"></a></p>
  
  <p>Why am i getting this error and how can it be fixed ?</p>