Skip to content

Instantly share code, notes, and snippets.

@radstevee
Last active January 29, 2025 18:12
Show Gist options
  • Save radstevee/cfb5ce4a1b546ebfabb344c30c172fdc to your computer and use it in GitHub Desktop.
Save radstevee/cfb5ce4a1b546ebfabb344c30c172fdc to your computer and use it in GitHub Desktop.
Gitlab runner creation via docker
#!/bin/bash
REGISTRATION_TOKEN="..." # Deprecated but eh
GITLAB_URL="https://gitlab.com"
container=$(docker run -d --restart always \
-v /srv/gitlab/runners/etc:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest)
echo "Created container $container"
docker exec "$container" gitlab-runner register \
--non-interactive \
--url "$GITLAB_URL" \
--registration-token "$REGISTRATION_TOKEN" \
--executor "docker" \
--docker-image "alpine:latest" \
--description "docker-runner" \
--tag-list "self-hosted"
echo "Registered runner!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment