actions/runner

Provide runner as a Docker Image

WtfJoke opened this issue ยท 15 comments

Describe the enhancement
Is it possible for you to provide official docker images for letting a runner run?

Additional information
We want to use self hosted runner, but we dont want to maintain machines/vms so it would be cool to have a ready to run official docker image in order to use them in services like aws fargate/azure container instances.

If im wrong here and I should have opened a topic in the github actions community forum please let me know and feel free to close the issue/feature request.

Some example of runner as a Docker image:

Additionally, Runner running in Docker is not able to use Docker itself:

throw new NotSupportedException("Container feature is not supported when runner is already running inside container.");

This is a major downside, as we can not yet manage self hosted runners with Kubernetes for example, as we have to manage VMs or real machines.

Thank you @vincentbrison for providing these examples, I found a couple of them as well, but I am not sure if we are allowed to use them in our company (we have a restriction to use only official images). Thats the reason why I asked here. :)

The hint about docker in docker is useful (a couple of application suffer of this problem). ๐Ÿ‘

I don't understand this limitation, what's the difference between this and a VM running in the machine? We are using M1 machines as our hosts and since the native runner on macOS does not support containers, we decided to use Docker, but when executing it, we get this error.

Also its possible with docker to run a docker conatiner in a docker container.
You only need to mount the docker directory /var/lib/docker in the normal file system so it doesnt gets mounted as an AUFS mountpoint.

This page i found describes a bit better than me: https://www.docker.com/blog/docker-can-now-run-within-docker/

@scolastico did you manage to do this?

are you able to run docker inside the docker container?

Run docker inside docker: Yes with the link from above (https://www.docker.com/blog/docker-can-now-run-within-docker/).
But my solution from my last comment was not from that. My main problem why i saw that issue was that i wanted clean runner instances for selfhosting and so i developed a small programm which exactly does this. Its starting automatically runners as they are needed and deletes used ones.

Hey everyone,

There is a bare-minimum runner image available now: ghcr.io/actions/actions-runner:latest
The Dockerfile is available here.

It is now part of the release process (#2250). The idea is to provide an image that can be used by actions-runner-controller, but also as a stand-alone image.

danm commented

hi @nikola-jokic how do you use this image?

docker run ghcr.io/actions/actions-runner:2.300.2 ?

Hey @danm,

You would need to provide an entrypoint. Keep in mind, the entrypoint should know how to configure and run the runner. The entrypoint by default does not exist. So imperatively, you can provide an --entrypoint with docker run, or you can use this Dockerfile as a base for building your own minimal runner image.

Spriz commented

Hi @nikola-jokic - thanks for providing those Dockerfiles - is there any plans to support docker in docker? We're in the process of migrating from Gitlab CI/CD to Github Actions and it seems quite agressive to run autoscaling VMs compared to running 1-2 dedicated machines that runs 5-10 instances (that are ephemeral) of that container.

Either being able to use docker-in-docker, or having the agent support multiple workspaces on the same VM would both solve this.

@danm did you get this runner working?

@nikola-jokic - I'm afraid I am not entirely following - could you elaborate on what needs to be done for the entry point? If I understand this right, by using the dockerfile you link to we can create our own images to set up runners and manage these?

Thanks in advance

danm commented

Hi @CarlSargunar
This is the way we are creating the runner using Docker.

Create a directory with 2 files, Dockerfile and runner.sh

The Dockerfile could look like this...

Dockerfile

FROM ghcr.io/actions/actions-runner:latest
RUN sudo apt update -y && sudo apt install build-essential git curl -y

RUN curl -sL https://deb.nodesource.com/setup_16.x -o ./tmp/nodesource_setup.sh
RUN sudo chmod +x ./tmp/nodesource_setup.sh
RUN sudo ./tmp/nodesource_setup.sh

COPY ./runner.sh .
CMD ["./runner.sh"]

runner.sh

#!/bin/sh

./config.sh --url https://github.com/$REPO --token $TOKEN --name $NAME --unattended
sudo ./bin/runsvc.sh

Run docker build --no-cache -t docker/github-runner . to build your image.
Run docker run docker/github-runner

Though I don't think you are supposed to use runsvc.sh anymore. Check the docs for the recommended. But it works great!

For anyone stumbling upon this in future, this one command should be enough. Just replace the URL and token.

โฏ docker run -it ghcr.io/actions/actions-runner:2.314.1 sh -c './config.sh --url https://github.com/<user or org>/<repo> --token <token> --unattended && ./run.sh'

(use docker run -d instead of docker run -it to run in the background)