title: Cannot connect to the Docker daemon when running with sudo
body: <p>My Docker service is up and running. However when attempting to use Docker by running it with <code>sudo</code>, e.g.:</p>
  
  <pre><code>12:40:26/~ $ sudo docker pull fluxcapacitor/pipeline
  Using default tag: latest
  </code></pre>
  
  <p>I have got the following error:</p>
  
  <pre><code>Warning: failed to get default registry endpoint from daemon (Cannot connect to 
  the Docker daemon. Is the docker daemon running on this host?). Using system 
  default: https://index.docker.io/v1/
  Cannot connect to the Docker daemon. Is the docker daemon running on this host?
  </code></pre>
  
  <p>Note that I had already followed the answers on <a href="https://stackoverflow.com/questions/36193300/mac-os-x-sudo-docker-cannot-connect-to-the-docker-daemon-is-the-docker-daemon-r">Mac OS X sudo docker Cannot connect to the Docker daemon. Is the docker daemon running on this host?</a></p>
  
  <p>as follows: </p>
  
  <p><strong>docker-machine start default</strong></p>
  
  <pre><code>12:40:36/~ $ docker-machine start default
  Starting "default"...
  Machine "default" is already running.
  </code></pre>
  
  <p><strong>docker ps</strong></p>
  
  <pre><code>12:41:20/~ $ docker ps
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
  </code></pre>
  
  <p>So what more needs to be done?</p>
  
  <p>This is:</p>
  
  <pre><code>$ docker --version
  Docker version 1.11.2, build b9f10c9
  </code></pre>
  
  <p>on <code>El Capitan</code>.</p>
  
  <p>Output of <code>docker-machine env default</code></p>
  
  <pre><code>$ eval "$(docker-machine env default)"
  
  $ docker-machine env default
  export DOCKER_TLS_VERIFY="1"
  export DOCKER_HOST="tcp://192.168.99.100:2376"
  export DOCKER_CERT_PATH="/Users/macuser/.docker/machine/machines/default"
  export DOCKER_MACHINE_NAME="default"
  </code></pre>