Is it possible to install and configure Docker on MacOS runner?

Is it possible to install and configure Docker on MacOS runner? Has anyone done it already and an example available?


I’d love to find a solution for this one as well. It’s the only thing blocking us from moving from CircleCI to GH Worfklows

1 Like


Many thanks for your feedback!  

According to the official doc, docker is not installed on hosted MacOS runner by default. Please use command to install it, code sample as below:

    runs-on: [macOS-latest]
      - name: echo
        run: |
          brew install docker-machine docker
          sudo docker –version

More install command can refer to this ticket,  or we can use a self-hosted macos runner to install docker.


I get the following error:

Client: Docker Engine - Community
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
 Version: 19.03.5
 API version: 1.40
 Go version: go1.13.4
 Git commit: 633a0ea
 Built: Thu Nov 14 23:51:40 2019
 OS/Arch: darwin/amd64
 Experimental: false
##[error]Process completed with exit code 1.

@timpetricola I would love to understand how not having docker on mac blocks you from moving from Circle?  I don’t understand needing to run on Mac but wanting to run your builds in a Linux container.

I am working on an iOS application where I’m running E2E tests. To do so I need to first build the application (using XCode, hence the Mac container) and start a server instance with docker.

But of course, for other flows, it’s not an issue :slight_smile:

@timpetricola that is a reasonable scneario.

Unfortuately the docker community licensing is such that we are not able to install the docker for mac on our hosted runners.  We have had some discussions with Docker about doing this but they have held firm on their request that using Docker on a service requires an enterprise license and docker enterprise is not at all supported on macOS.

For Windows Microsoft holds the license for Docker Enterprise on Windows so we do not have any issues there and for Linux we use a specific build of Docker for Linux that is built and maintained by Azure.

1 Like

@chrispatthanks a lot for the explanations!

I got a bit further with Docker on MacOS:

# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------

    runs-on: macos-latest

      fail-fast: false
          - "7.2"
          - "nginx-stable"

    name: "[PHP ${{ matrix.php }}] vs [${{ matrix.httpd }}]"

      # ------------------------------------------------------------
      # Checkout repository
      # ------------------------------------------------------------
      - name: Checkout repository
        uses: actions/checkout@v1

      - name: "[Pre] Install Requirements"
        shell: bash
        run: |
          brew install coreutils
          brew install bash
          brew install socat

      - name: "[Pre] Install Docker"
        shell: bash
        run: |
          brew install docker docker-machine-driver-xhyve
          sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
          sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
          while ! docker-machine create --driver xhyve default; do
            docker-machine rm -f default
            sleep 1;
          # Export variable (this target)
          eval "$(docker-machine env default)"
          DOCKER_TLS_VERIFY="$( docker-machine env default | grep DOCKER_TLS_VERIFY | sed -e 's/.*="//g' -e 's/"$//g' )"
          DOCKER_HOST="$( docker-machine env default | grep DOCKER_HOST | sed -e 's/.*="//g' -e 's/"$//g' )"
          DOCKER_CERT_PATH="$( docker-machine env default | grep DOCKER_CERT_PATH | sed -e 's/.*="//g' -e 's/"$//g' )"
          DOCKER_MACHINE_NAME="$( docker-machine env default | grep DOCKER_MACHINE_NAME | sed -e 's/.*="//g' -e 's/"$//g' )"
          # Export variable (this other targets)
          echo ::set-env name=DOCKER_TLS_VERIFY::${DOCKER_TLS_VERIFY}
          echo ::set-env name=DOCKER_HOST::${DOCKER_HOST}
          echo ::set-env name=DOCKER_CERT_PATH::${DOCKER_CERT_PATH}
          echo ::set-env name=DOCKER_MACHINE_NAME::${DOCKER_MACHINE_NAME}
          # Show info
          docker-machine ls
          docker-machine env default
          docker version

      - name: "[Pre] Install Docker Compose"
        shell: bash
        run: |
          sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
          sudo chmod +x /usr/local/bin/docker-compose
          docker-compose version

      - name: "[Pre] Setup Docker machine"
        shell: bash
        run: |
          # Setup DNS records
          echo " localhost" | sudo tee -a /etc/hosts

          # Portforwarding from DOCKER_HOST to local
          HOST="$( echo "${DOCKER_HOST}" | sed -e 's|^tcp://||g' -e 's|:.*||g' )"
          echo "${HOST}"
          sudo socat -s -d -d tcp-listen:80,reuseaddr,fork tcp:${HOST}:80 &
          sleep 2
          sudo socat -s -d -d tcp-listen:443,reuseaddr,fork tcp:${HOST}:443 &
          sleep 2
          if ! netstat -an | grep -i LISTEN | grep -E '(:80)|(\.80)\s'; then
            netstat -an | grep -i LISTEN;
          if ! netstat -an | grep -i LISTEN | grep -E '(:443)|(\.443)\s'; then
            netstat -an | grep -i LISTEN;
          host localhost
          curl -sS -I 'http://localhost:80' || true
          curl -sS -I 'https://localhost:443' || true

      - name: "[Info] Show environment"
        shell: bash
        run: |
        if: success() || failure()

      - name: "[Info] Show network"
        shell: bash
        run: |
          netstat -an || true
          ss -tlun || true
        if: success() || failure()

However, the issue I now have is that (even docker-compose was installed successfully and works) no directories are being mounted into my Docker stack.

@timpetricoladid you ever manage to get a workflow running on MacOS with docker.

I have exactly the same scenario at the moment.



I actually didn’t investigate further as our current setup is working well on CircleCI and there is no rush to change

@chrispat It seems like Docker Desktop Enterprise for Mac is now available, does this unblock the licensing/macOS support issue?