2

I have run into an issue when trying to run circleci build locally on macOS when trying to build a docker image.

Example .config file

version: 2
jobs:
  build:
    docker:
      - image: cimg/base:2020.01
    steps:
      - setup_remote_docker
      - run:
          name: Run Docker
          command: docker run cimg/base:2020.01 echo "hello"

After running circleci build

failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: permission denied

I've looked at several similar questions such as this one but none of their solutions work.

Lawson Fulton
  • 121
  • 1
  • 7

1 Answers1

2

I was able to adapt the solution here to work with circleci.

Simply add the command sudo chown circleci:circleci /var/run/docker.sock to your circle config.

So it will look like:

version: 2
jobs:
  build:
    docker:
      - image: cimg/base:2020.01
    steps:
      - setup_remote_docker
      - run: if [ -e /var/run/docker.sock ]; then sudo chown circleci:circleci /var/run/docker.sock; fi
      - run:
          name: Run Docker
          command: docker run cimg/base:2020.01 echo "hello"

And the result

====>> Run Docker
  #!/bin/bash -eo pipefail
docker run cimg/base:2020.01 echo "hello"
hello
Success!
Lawson Fulton
  • 121
  • 1
  • 7