docker-github-runner
docker-github-runner copied to clipboard
[Feature] Use container name as runner name
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
... 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
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.