dockergithub-actionsdocker-apibuilding-github-actions

Act Not able to Use Docker API


I am trying to locally test github actions with the open-source Act utility.

"Think globally, act locally"

I have copied the git hub repository for which i want to check github action and it does contains .github/workflow folders.
I run this command to run my github action.

act -v workflow_dispatch

It gives this error

DEBU[0000] Loading environment from /home/harshal/harshal/open-horizon.github.io/.env 
DEBU[0000] Loading secrets from /home/harshal/harshal/open-horizon.github.io/.secrets 
DEBU[0000] Loading workflows from '/home/harshal/harshal/open-horizon.github.io/.github/workflows' 
DEBU[0000] Loading workflows recursively                
DEBU[0000] Found workflow 'anaxdocscopy.yml' in '/home/harshal/harshal/open-horizon.github.io/.github/workflows/anaxdocscopy.yml' 
DEBU[0000] Found workflow 'link-snitch.yml' in '/home/harshal/harshal/open-horizon.github.io/.github/workflows/link-snitch.yml' 
DEBU[0000] Reading workflow '/home/harshal/harshal/open-horizon.github.io/.github/workflows/anaxdocscopy.yml' 
DEBU[0000] Correcting if statements '/home/harshal/harshal/open-horizon.github.io/.github/workflows/anaxdocscopy.yml' 
DEBU[0000] Reading workflow '/home/harshal/harshal/open-horizon.github.io/.github/workflows/link-snitch.yml' 
DEBU[0000] Correcting if statements '/home/harshal/harshal/open-horizon.github.io/.github/workflows/link-snitch.yml' 
DEBU[0000] Planning event: workflow_dispatch            
DEBU[0000] Loading slug from git directory '/home/harshal/harshal/open-horizon.github.io/.git' 
DEBU[0000] Found revision: a632f3efe8b7c29bc69794bcbf1f6ecd323467f0 
DEBU[0000] Loading revision from git directory '/home/harshal/harshal/open-horizon.github.io/.git' 
DEBU[0000] Found revision: a632f3efe8b7c29bc69794bcbf1f6ecd323467f0 
DEBU[0000] HEAD points to 'a632f3efe8b7c29bc69794bcbf1f6ecd323467f0' 
DEBU[0000] using github ref: refs/heads/master          
DEBU[0000] context env => map[ACT:true ISSUE_TEMPLATE:.github/ISSUE_TEMPLATE/check-broken-links.md URL:https://open-horizon.github.io/] 
DEBU[0000] context needs => map[]                       
[Link Snitch/build] 🚀  Start image=catthehacker/ubuntu:act-latest
DEBU[0000] Loading slug from git directory '/home/harshal/harshal/open-horizon.github.io/.git' 
DEBU[0000] Found revision: a632f3efe8b7c29bc69794bcbf1f6ecd323467f0 
DEBU[0000] Loading revision from git directory '/home/harshal/harshal/open-horizon.github.io/.git' 
DEBU[0000] Found revision: a632f3efe8b7c29bc69794bcbf1f6ecd323467f0 
DEBU[0000] HEAD points to 'a632f3efe8b7c29bc69794bcbf1f6ecd323467f0' 
DEBU[0000] using github ref: refs/heads/master          
[Link Snitch/build]   🐳  docker pull catthehacker/ubuntu:act-latest
DEBU[0000] FIXME: Got an status-code for which error does not match any expected type!!!: -1  module=api status_code=-1
DEBU[0000] Image exists? false                          
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
DEBU[0000] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied
unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" () 
Error: unable to determine if image already exists for image "catthehacker/ubuntu:act-latest" (): Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json?filter=catthehacker%2Fubuntu%3Aact-latest": dial unix /var/run/docker.sock: connect: permission denied

I am new to docker and I literally don't know anything about it just that it creates containers(similar to OS) for running softwares. I tried searching on github issues for Act but could not find anything.
I installed docker with sudo snap install docker then I checked with echo $? which gave out 0 and docker -v which gave out Docker version 20.10.8, build 3967b7d28e, so it seems like I do have running docker installed then still why it is giving this error.
And here is the github action/workflow file I wrote

name: Link Snitch

on:
  schedule:
    - cron:  '0 1 1 * *'
  workflow_dispatch:
  
 
env:
  URL: https://open-horizon.github.io/
  ISSUE_TEMPLATE: ".github/ISSUE_TEMPLATE/check-broken-links.md"

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - name: Check out master
        uses: actions/checkout@master
        with:
          fetch-depth: 1

      - name: Report broken links
        uses: victoriadrake/link-snitch@master
        with:
          Resursive urls: true
          URL: https://open-horizon.github.io/

        if: ${{ failure() }}
      - uses: JasonEtco/create-an-issue@v2.4.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          filename: ${{ env.ISSUE_TEMPLATE }}
        if: ${{ failure() }}

Solution

  • This is a docker issue, because you want to run docker as a non-root user. You need to add docker to the docker group.

    This answer gives a detailed explanation on how to fix it. For me, running sudo usermod -a -G docker $USER and then rebooting worked.