title: Docker: permission denied while trying to connect to Docker Daemon with local CircleCI build
body: <p>I have a very simple <code>config.yml</code>:</p>
  
  <pre><code>version: 2
  
  jobs:
    build:
      working_directory: ~/app
      docker:
        - image: circleci/node:8.4.0
      steps:
        - checkout
        - run: node -e "console.log('Hello from NodeJS ' + process.version + '\!')"
        - run: yarn
        - setup_remote_docker
        - run: docker build .
  </code></pre>
  
  <p>All it does: boot a <code>node</code> image, test if node is running, do a <code>yarn install</code> and a <code>docker build</code>.</p>
  
  <p>My dockerfile is nothing special; it has a COPY and ENTRYPOINT.</p>
  
  <p>When I run <code>circleci build</code> on my MacBook Air using Docker Native, I get the following error:</p>
  
  <p><code>Got permission denied while trying to connect to the Docker daemon socket at unix://[...]</code></p>
  
  <p>If I change the <code>docker build .</code> command to: <code>sudo docker build .</code>, everything works as planned, locally, with <code>circleci build</code>.<br>
  <strong>However</strong>, pushing this change to CircleCI will result in an error: <code>Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?</code></p>
  
  <p>So, to summarize: using <code>sudo</code> works, locally, but not on CircleCI itself. <strong>Not</strong> using <code>sudo</code> works on CircleCI, but not locally. </p>
  
  <p>Is this something the CircleCI staff has to fix, or is there something I can do?</p>
  
  <p><a href="https://discuss.circleci.com/t/circleci-build-local-machine-fails-when-using-setup-remote-docker" rel="noreferrer">For reference, I have posted this question on the CircleCI forums as well.</a></p>