Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide runner as a Docker Image #367

Closed
WtfJoke opened this issue Mar 11, 2020 · 15 comments
Closed

Provide runner as a Docker Image #367

WtfJoke opened this issue Mar 11, 2020 · 15 comments
Labels

Comments

@WtfJoke
Copy link

WtfJoke commented Mar 11, 2020

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.

@WtfJoke WtfJoke added the enhancement New feature or request label Mar 11, 2020
@vincentbrison
Copy link

vincentbrison commented Mar 11, 2020

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.

@WtfJoke
Copy link
Author

WtfJoke commented Mar 13, 2020

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). 👍

@ppamorim
Copy link

ppamorim commented Aug 4, 2021

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.

@scolastico
Copy link

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/

@pdomagala-tl
Copy link

@scolastico did you manage to do this?

@scolastico
Copy link

not in this way but in another: https://github.com/scolastico-dev/s.RunnerManager

@pdomagala-tl
Copy link

are you able to run docker inside the docker container?

@scolastico
Copy link

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.

@nikola-jokic
Copy link
Contributor

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
Copy link

danm commented Jan 6, 2023

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

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

@nikola-jokic
Copy link
Contributor

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
Copy link

Spriz commented Jan 17, 2023

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.

@CarlSargunar
Copy link

@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
Copy link

danm commented Apr 13, 2023

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!

@uhthomas
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests