question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Runner inside of Docker Container

See original GitHub issue

Describe the enhancement

Fully support all features when runner is within a Docker container.

Not all features are currently supported when the runner is within a Docker container, specifically those features that use Docker like Docker-based Actions and services. Running self-hosted runners using Docker is an easy way to scale out runners on some sort of Docker-based cluster and an easy way to provide clean workspaces for each run (with ./run.sh --once).

Code Snippet

Possible implementation that I am using now.

Additional information

There are a few areas of concern when the runner executes in a Docker container:

  1. Filesystem access for other containers needed as part of the job. This can be resolved by using a volume mount from the host which uses a matching host and container path (for example: docker run -v /home/github:/home/github, although it doesn’t have to be this exact directory) and telling the runner to use a directory within that for the work directory (./config.sh --work /home/github/work). This works with the current volume mounting behaviour for containers created by the runner. This would need to be documented as part of the setup process for a Docker-based runner.
  2. Network between runner and other containers needed as part of the job. This could be resolved by not creating a network as part of the run and instead optionally accepting an existing network to be used. I have found that it works well to use --network container:<container ID of the runner> to reuse the network from the runner container without having to orchestrate a network created via docker network create. There is no straightforward way to discover the network or ID of a container from within it, so it would likely need to be the responsibility of the user to pass this information to the runner (I current do something like "container:$(cat /proc/self/cgroup | grep "cpu" | head -n 1 | rev | cut -d/ -f 1 | rev)" from within the runner container to find the ID and pass this to the runner, although this isn’t guaranteed to work in all cases).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:219
  • Comments:43 (3 by maintainers)

github_iconTop GitHub Comments

50reactions
brandonschabellcommented, Jul 13, 2021

Would love to see this prioritized. Can’t really run docker-in-docker on Kubernetes self-hosted runners without this.

32reactions
nehagargSeequentcommented, Aug 18, 2021

Any update on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run GitLab Runner in a container
Tutorial: Create a custom workspace image that supports arbitrary user IDs ... Docker · Run CI/CD jobs in Docker containers · Use Docker...
Read more >
How to register & run GitLab Runner inside a Docker container
You can run GitLab Runner inside a Docker container and register to GitLab running in Docker -desktop on Windows.
Read more >
docker exec
The docker exec command runs a new command in a running container. The command started using docker exec only runs while the container's...
Read more >
Create a Docker based Self Hosted GitHub runner Linux ...
In part one of this series, we looked at how we can create a windows container image using docker and then running our...
Read more >
Deploying Self-Hosted GitHub Actions Runners with Docker
This tutorial looks at how to deploy self-hosted GitHub Actions runners with Docker and Docker Swarm to DigitalOcean.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found