gitlab cicd (三)系列之安装git-runner docker安装方式

本编博客是继gitlab cicd (二)系列之安装git-runner rpm安装方式之后另一种安装gitlab-runner的安装方式—容器安装方式

1.安装docker
请参考安装docker 17.03.2.ce教程

docker版本

[root@gitlab-runner-64 ~]# docker version 
Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:48:22 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:19:08 2018
  OS/Arch:          linux/amd64
  Experimental:     false

启动gitlab-runner

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

或者可以使用第三方存储valume的启动方式

 docker run -d --name gitlab-runner-config \
     -v /etc/gitlab-runner \
     busybox:latest \
     /bin/true

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

向gitlab服务注册gitlab-runner

gitlab token 获取如下图
000

执行命令,具体注册方式参考下图

 docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register

docker

执行完成之后,会有以下文件生成/srv/gitlab-runner/config

[root@gitlab-runner-64 ~]# cat /srv/gitlab-runner/config/config.toml 
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "docker-runner"
  url = "http://10.39.47.63/"
  token = "d4027a7f23390e8e2519d93564c0a7"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "golang:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock","/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

启动gitlab-runner

在这里插入图片描述

[root@gitlab-runner-64 ~]# docker ps 
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS               NAMES
d77ff46d00d2        gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   51 seconds ago      Up 51 seconds                           gitlab-runner

查看是否已经注册完成
9090

执行效果
在这里插入图片描述
end

参考:

Run GitLab Runner in a container
Registering Runners

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值