📅  最后修改于: 2023-12-03 15:14:46.092000             🧑  作者: Mango
Docker Run GitLab Runner is a great way to automate your CI/CD process. When using GitLab Runner, you can execute CI/CD pipelines for your projects.
This article describes how to use Docker to run GitLab Runner with the Shell/Bash executor.
Before proceeding, make sure you have the following:
The first step is to pull the GitLab Runner open-source image using Docker. You can pull the image by running the following command:
docker pull gitlab/gitlab-runner:latest
To register the GitLab Runner, you'll first need to retrieve the registration token from your GitLab project. You can do this by navigating to the Settings > CI/CD section of your project and copy the token from the Runner registration token section.
Next, you need to run the following command to register the GitLab Runner:
docker run -it --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--executor "shell" \
--url "https://gitlab.com/" \
--registration-token "YOUR_REGISTRATION_TOKEN" \
--description "YOUR_RUNNER_DESCRIPTION" \
--tag-list "YOUR_TAG_LIST" \
--run-untagged="true" \
--locked="false"
Here is what each of the command options does:
-it
- Runs the container in interactive mode and creates a tty terminal.--rm
- Removes the container upon exit.-v /srv/gitlab-runner/config:/etc/gitlab-runner
- Mounts the GitLab Runner configuration directory.--non-interactive
- Runs the registration command in non-interactive mode.--executor "shell"
- Specifies the runner executor type.--url "https://gitlab.com/"
- Specifies the URL of your GitLab instance.--registration-token "YOUR_REGISTRATION_TOKEN"
- Specifies the Runner registration token.--description "YOUR_RUNNER_DESCRIPTION"
- Specifies a description for the Runner.--tag-list "YOUR_TAG_LIST"
- Specifies a comma-separated list of runner tags.--run-untagged="true"
- Allows the Runner to run untagged jobs.--locked="false"
- Specifies that the Runner is not locked and can be used by any project.After registering the Runner, you can start it by running the following command:
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
Here is what each of the command options does:
-d
- Runs the container in detached mode.--name gitlab-runner
- Specifies a name for the container.--restart always
- Automatically restarts the container upon exit.-v /srv/gitlab-runner/config:/etc/gitlab-runner
- Mounts the Runner configuration directory.gitlab/gitlab-runner:latest
- Specifies the GitLab Runner image to run.In this article, you learned how to use Docker Run GitLab Runner with the Shell/Bash executor. You pulled the Runner image, registered a new Runner and started it using Docker. Now you can leverage the GitLab Runner to speed up your CI/CD pipeline in your projects.