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

[Feature] Use container name as runner name #48

Open
tdamsma opened this issue Jul 8, 2021 · 3 comments
Open

[Feature] Use container name as runner name #48

tdamsma opened this issue Jul 8, 2021 · 3 comments

Comments

@tdamsma
Copy link

tdamsma commented Jul 8, 2021

When setting up a bunch of runners with docker-compose up --scale runner=10 is is not possible (as far as I know) to give each container a unique value for the RUNNER)NAME, so i the runners each have a unique container name, and it would be great if that could be used as the runner name.

The workarounds i saw are

  • leave the runner name empty and get a random name asigned
  • use copy/paste in the docker compose instead of the scale functionality
@tdamsma
Copy link
Author

tdamsma commented Jul 9, 2021

... and looking into the entrpoint this isalready exactly how it works

if [[ -z $RUNNER_NAME ]]; then
    echo "RUNNER_NAME environment variable is not set, using '${HOSTNAME}'."
    export RUNNER_NAME=${HOSTNAME}
fi

@tdamsma tdamsma closed this as completed Jul 9, 2021
@tdamsma tdamsma reopened this Jul 9, 2021
@tdamsma
Copy link
Author

tdamsma commented Jul 9, 2021

I thought the hostname ws the container name but it is not. The container name can be retreived with $(docker inspect -f "{{ .Name }}" ${HOSTNAME} | cut -c 2-). I changed the entrypoint.sh for my uses with:

if [[ -z $RUNNER_NAME ]]; then
    export RUNNER_NAME=$(docker inspect -f "{{ .Name }}" ${HOSTNAME} | cut -c 2-)
    echo "RUNNER_NAME environment variable is not set, using '${RUNNER_NAME}' derived from the container name."
fi

This allows me to use docker-compose up --scale runner=10 and get predictable runner names, so that if I recreate the docker-compose environment I get the same runner names.

@beeb
Copy link

beeb commented May 4, 2023

this is supported with this (actively maintained) image: https://github.com/myoung34/docker-github-actions-runner

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

No branches or pull requests

2 participants