Self-hosted GitHub Actions runner cannot access /var/run/docker.sock when launched as systemd service
Environment
Ubuntu 22.04 VM running GitHub Actions runner installed as systemd service (runner v2.x), Docker Engine 20.10, runner service unit sets User=ci-runner and uses Workspace under /home/ci-runner
Symptoms
Workflows that call docker CLI fail immediately with 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?' from the runner; jobs time out and are marked failed.
Observations
docker.sock exists at /var/run/docker.sock (srw-rw---- root:docker). The runner process runs as ci-runner user. journalctl for runner shows 'permission denied' when opening socket. Adding ci-runner to docker group on host and restarting user shell fixed access for interactive login but runner service still fails.
Already attempted
Chowning/chmodding socket to 666 (temporary) allowed jobs to run; restarted runner service after adding group membership (no effect). Reviewed systemd unit: no Groups= or SupplementaryGroups set. AppArmor not enforcing on docker.sock path.
Question
How can I safely allow the systemd-managed self-hosted runner service to access Docker socket without making the socket globally writable or compromising host security?
Verified community troubleshooting
First check the runner's systemd unit — systemd doesn't automatically pick up new supplementary groups for a running service. Add Group=docker or SupplementaryGroups=docker to the unit file instead of chmodding /var/run/docker.sock. Example: edit /etc/systemd/system/actions.runner.<name>.service, add Group=docker under [Service], then sudo systemctl daemon-reload && sudo systemctl restart actions.runner.<name>.service. Verify by reproducing a workflow that calls docker or running sudo -u ci-runner docker ps. If you need stronger hardening, remove broad group grants and instead use a carefully-scoped bind-mount or socket proxy (or run the runner in a short-lived container). If AppArmor/SELinux is enabled, check audit logs before changing permissions. This avoids making the socket world-writable and is reversible by restoring the unit file and restarting the service.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux29% match
systemd service fails to start with status=203/EXEC for Node app after unit file change
Open0 answers - Software28% match
Self-hosted GitHub Actions runners produce incomplete multi-stage Docker images after kernel update (overlay2: missing build artifacts)
Open0 answers - Linux27% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer - Linux26% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer - Linux25% match
systemd socket-activated service times out after moving /var to separate partition
Open0 answers