actions / actions/runner

Runner ignores DOCKER_HOST variable when starting container

Open
#827 6 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Runner Feature
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug
I tried to run a self hosted github runner with rootless docker. I added

XDG_RUNTIME_DIR=/home/runner/.docker/run
DOCKER_HOST=unix:///home/runner/.docker/run/docker.sock

to .env and /home/runner/bin to .path. In general github actions and rootless docker work fine.

When the container is initialized it runs

/home/runner/bin/docker create --name 395a5f555e924b28bf52524b85bb3eee_docker1903dind_710b8c --label d94681 --workdir /__w/actionstest/actionstest --network github_network_1c96635676ce470c8b9cb5f86ec01f5c
  -e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/actions-runner/_work":"/__w" -v "/home/runner/actions-runner/externals":"/__e":ro -v "/home/runner/actions-runner/_work/_temp":"/__w/_temp" -v "/home/runner/actions-runner/_work/_actions":"/__w/_actions"
 -v "/home/runner/actions-runner/_work/_tool":"/__w/_tool" -v "/home/runner/actions-runner/_work/_temp/_github_home":"/github/home" -v "/home/runner/actions-runner/_work/_temp/_github_workflow":"/github/workflow" --entrypoint "tail" docker:19.03-dind "-f" "/dev/null"

As you can see it tries to volume mount the non existing /var/run/docker.sock from the host, which prevents any dind image from working. It seems this value is hardcoded here and DOCKER_HOST is ignored.

To Reproduce
Steps to reproduce the behavior:

  1. Create a self hosted runner using rootless docker
  2. Start a build with a step running inside a container

Expected behavior
/var/run/docker.sock should not be hard coded. DOCKER_HOST should be used if set.

Runner Version and Platform

Version of your runner? 2.274.2

OS of the machine running the runner? Linux, Ubuntu 18.04

Job Log Output

Runner starts the build step with

/home/runner/bin/docker create -[...] -v "/var/run/docker.sock":"/var/run/docker.sock" [...]

which makes this job

  dind-test:
    container: docker:19.03-dind
    runs-on: self-hosted
    steps:
      - run: docker ps

fail:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/Runner.Worker/Container/ContainerInfo.cs at the linked line and trace how the container's Docker socket volume is selected. Reproduce the rootless Docker setup described in the issue, then verify that the container command uses DOCKER_HOST when it is set instead of hard-coding /var/run/docker.sock.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.