You can run GitLab in a container in Docker-desktop on Windows. Follow this link. Once GitLab is running in a container and accessible using a link like http://localhost, now GitLab-runner can be run in another container in Docker-desktop and register it with GitLab to execute your pipeline.

Steps:

–> Create Docker named volume

#create vol in docker
docker volume create gitlab-runner-config

 

–> Start the GitLab-runner by mounting the docker volume created earlier-

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

 

–> Register the runner with GitLab-

Before running the below command to register the runner, keep this information handy-

  • Find GitLab instance URL– Use this command
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <REPLACE GITLAB CONTAINER ID HERE>
    

    to find the GitLab container IP  first (NOT the gitlab-runner container) in Docker-desktop. The the GitLab instance URL will be http://<Container IP>:80

  • Get the Registration Token– Login to GitLab using root user and go to Menu–>Admin, copy the token

Register gitlab-runner-

docker run --rm -it -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner register

Provide the following information for the prompts-

Enter the GitLab instance URL (for example, https://gitlab.com/):
http://<REPLACE GITLAB CONTAINER IP HERE>:80
Enter the registration token:
<PROVIDE TOKEN HERE>
Enter a description for the runner:
[9079a98977a4]: <PROVIDE NAME for RUNNER>
Enter tags for the runner (comma-separated):
<PROVIDE TAG>
Enter optional maintenance note for the runner:
<OPTIONAL>

If registration is successful, it will prompt for runner executor with options, select “shell” or any other executor you want.

Once the runner is registered, it will show up under Runners in GitLab as shown-

You can watch – https://www.youtube.com/watch?v=JLdPiq0owUM