Skip to content

Instantly share code, notes, and snippets.

@orihomie
Last active March 12, 2024 09:45
Show Gist options
  • Save orihomie/537d3cb01a3e42bae5fa8eb937e53ad0 to your computer and use it in GitHub Desktop.
Save orihomie/537d3cb01a3e42bae5fa8eb937e53ad0 to your computer and use it in GitHub Desktop.
This is how you register gitlab runner to run in docker
#!/usr/bin/env bash
token=$1
url=$2
name=$3
docker_image_version="docker:dind"
tags=$4
docker_user="root"
docker run --rm -it -v /data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
-n \
--url "${url}" \
--registration-token "${token}" \
--executor "docker" \
--description "${name}" \
--docker-image "${docker_image_version}" \
--docker-volumes /cache \
--docker-volumes /builds:/builds \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--docker-privileged \
--docker-user "${docker_user}" \
--tag-list "${tags}" \
--paused \
--locked="false" \
--access-level="not_protected"
@orihomie
Copy link
Author

orihomie commented Feb 3, 2023

docker run -d --name gitlab-runner --restart always gitlab/gitlab-runner

@orihomie
Copy link
Author

orihomie commented Feb 3, 2023

docker run -d --name gitlab-runner --restart always -v /data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner

@orihomie
Copy link
Author

orihomie commented Feb 3, 2023

docker run -d --name gitlab-runner --restart always -v /data/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner

@orihomie
Copy link
Author

orihomie commented Apr 19, 2023

CI_PROJECT_DIR answers the following formula:

/builds/${CI_RUNNER_SHORT_TOKEN}/${CI_CONCURRENT_PROJECT_ID}/${CI_PROJECT_PATH}

https://docs.gitlab.com/runner/configuration/advanced-configuration.html#default-build-directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment