栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

How to start a gitlab-runner in wsl?

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

How to start a gitlab-runner in wsl?

Becasue I've installed the Ubuntu 18.04 LTS in my wsl, I click the icon to start.

1.Start wls2 and docker

# showing docker status
  service docker status
# start docker service by root
  sudo service docker start

 2.Download the gitlab-runner docker image

Command: docker pull {the image name from gitlab}
For example: 
  docker pull gitlab/gitlab-runner:latest

3.Show docker images

docker images

 4.Start the docker container (Docker run)

Command: docker run -it -v {local path of wsl}:{container path} --rm --name {docker image name} 
    How to get a docker image name that you need, please enter the command: docker images
    Hwo to enter the local path of wsl from Windows, please enter the command: \wsl$Ubuntu-18.04
    -v: --volume
    --rm: If you exit the docker container, it will be not showed. command: docker ps -a 
  For example: 
    docker run -it 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/run/docker.sock:/var/run/docker.sock 
	--rm --name gitlab-runner gitlab/gitlab-runner:latest
    or
    docker run -it 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner 
	-v /var/run/docker.sock:/var/run/docker.sock 
	--rm --name gitlab-runner gitlab/gitlab-runner:latest

5.Go to the gitlab-runner container

Command: docker exec -it {container id} /bin/bash
For example: 
  docker exec -it 96f62c0a7ddf /bin/bash 

6.Register

docker run --rm -it -v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
  Enter the GitLab instance URL (for example, https://gitlab.com/):
    https://gitlab.xxx.com/
  Enter the registration token:
    xxx
  Enter a description for the runner:
    WebApp runner on wsl 
  Enter tags for the runner (comma-separated):
    rubin-runner-wsl01
  Enter optional maintenance note for the runner:
    xxx
  Enter an executor: custom, shell, kubernetes, docker-ssh+machine, docker, docker-ssh, parallels, ssh, virtualbox, docker+machine:
   docker
  Enter the default Docker image (for example, ruby:2.7):
   alpine:laster

  Or
  docker run -it --rm -v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register 
  --non-interactive 
  --executor "docker" 
  --docker-image alpine:latest 
  --url "https://gitlab.xxx.com/" 
  --registration-token "xxx" 
  --description "WebApp runner on wsl" 
  --tag-list "rubin-runner-wsl01" 

7.If it's showing the error: x509: certificate signed by unknown authority

  7.1 check the daemon.json of docker

sudo vi /etc/docker/daemon.json

  7.2 add the url of your gitlab into it

{
   "insecure-registries":["https://harbor.xxx.com","https://gitlab.xxx.com"]
}

  7.3 Enter Esc and input ":wq" to save and exit

  7.4 install cert

openssl s_client -showcerts -connect gitlab.xxx.com:443 -servername gitlab.xxx.com < /dev/null 2>/dev/null | openssl x509 -outform PEM > /etc/gitlab-runner/certs/gitlab.xxx.com.crt

  7.5 verify cert

echo | openssl s_client -CAfile /etc/gitlab-runner/certs/gitlab.xxx.com.crt -connect gitlab.xxx.com:443 -servername gitlab.xxx.com

 8.Start the docker container (Docker run)

docker run -it 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/run/docker.sock:/var/run/docker.sock 
	--rm --name gitlab-runner gitlab/gitlab-runner:latest

 9.After you've installed the gitlab-runner, you only run the step 1 and 8.

sudo service docker start
docker run -it 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner 
	-v /mnt/d/Tools/DevOps/wsl/gitlab-runner/run/docker.sock:/var/run/docker.sock 
	--rm --name gitlab-runner gitlab/gitlab-runner:latest

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/973567.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号