fortytwoservices / terraform-azurerm-selfhostedrunnervmss

Module for creating a simple virtual machine scale set for Azure DevOps and GitHub self hosted runners
MIT License
2 stars 2 forks source link

Bug: VMSS user unable to interact with Docker #60

Closed tim-chaffin closed 11 months ago

tim-chaffin commented 11 months ago

The user within the GitHub runner is unable to interact with the Docker daemon. Take the following GitHub action:

name: GitHub and Containers

on: [workflow_dispatch]

jobs:
  Test-Containers:
    runs-on: [self-hosted, standard-size]

    container:
      image: <example container host>/some-container:latest
      credentials:
        username: ${{ secrets.USERNAME }}
        password: ${{ secrets.PASSWORD }}

This returns the following error:

 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/version": dial unix /var/run/docker.sock: connect: permission denied

The solution I've found is to go onto the VMSS its self, and update the user permissions:

sudo usermod -a -G docker $USER

This required me to restart the VMSS instance, but that fixed it. In the install script file, perhaps we could add the usermod statement.

tim-chaffin commented 11 months ago

Validated fix after merge. Good to go.