前提:1.服務(wù)器能連外網(wǎng)
?????????? 2.服務(wù)器已經(jīng)安裝好docker-ce
一.安裝gitlab
[root@localhost ~]# mkdir -p /opt/gitlab/config /opt/gitlab/logs /opt/gitlab/data
[root@localhost ~]# docker pull gitlab/gitlab-ce:12.9.0-ce.0
[root@localhost ~]# docker run -d? -p 443:443 -p 80:80 -p 222:22 --name gitlab --restart always -v /opt/gitlab/config:/etc/gitlab -v /opt/gitlab/logs:/var/log/gitlab -v /opt/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:12.9.0-ce.0
[root@localhost config]# docker exec -it gitlab bash
root@416a1bfe8f29:/#?vim /etc/gitlab/gitlab.rb
29 external_url 'http://192.168.66.222:80'
1155 nginx['listen_port'] = 80
:wq
root@416a1bfe8f29:/# gitlab-ctl reconfigure
[root@localhost config]# docker restart 416a1bfe8f29
瀏覽器訪問:http://192.168.66.222:80即可登錄,首次登錄要強(qiáng)制修改密碼,否則無法登錄,默認(rèn)登錄用戶為root
二.安裝gitlab-runner
[root@localhost ~]# mkdir -p /opt/gitlab-runner-01/config
[root@localhost ~]# docker pull gitlab/gitlab-runner:v12.6.0
[root@localhost ~]# docker run? -t -id --restart always --name gitlab-runner-01 -v /opt/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:v12.6.0
三.gitlab-runner注冊(cè)
知識(shí)點(diǎn)
GitLabRunner 類型
shared: 運(yùn)行整個(gè)平臺(tái)項(xiàng)目的作業(yè)(gitlab)
group: 運(yùn)行特定group下的所有項(xiàng)目的作業(yè)(group)
specific:運(yùn)行指定的項(xiàng)目作業(yè)(project)
locked: 無法運(yùn)行項(xiàng)目作業(yè)
paused: 不會(huì)運(yùn)行作業(yè)
步驟一:去gitlab網(wǎng)頁(yè),進(jìn)入系統(tǒng)設(shè)置-> Runners,獲取shared類型runnertoken

步驟二:注冊(cè)
方式1: 啟動(dòng)容器交互式注冊(cè)
備注:其中有刪除線的為URL和token
[root@localhost ~]# docker run --restart always -itd --name?gitlab-runner-01 -v /opt/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:v12.6.0
[root@localhost ~]# docker exec -it gitlab-runner-01 bash
[root@localhost ~]# gitlab-runner register
Runtime?platform ???????????????????????????????????arch=amd64 os=linux pid=6?revision=ac8e767a version=12.6.0
Running?in system-mode.
Please?enter the gitlab-ci coordinator URL?(e.g. https://gitlab.com/):
Please?enter the gitlab-ci token for?this?runner:oQMz4sA3WgB7LaGSaZvH
Please?enter the gitlab-ci description for?this?runner:
[00e4f023b5ae]: gitlab-runner-01
Please?enter the gitlab-ci tags for?this?runner (comma separated):
buildRegistering?runner... succeeded ????????????????????runner=4tutaeWW
Please?enter the executor: parallels, virtualbox, docker-ssh+machine, kubernetes, docker+machine, custom, docker, docker-ssh, shell, ssh:
Shell
Runner?registered successfully. Feel?free to start it, but if?it's?running already the config should be automatically reloaded!
方式二:直接注冊(cè)
1.自動(dòng)注冊(cè)
[root@localhost ~]# docker run -itd --restart always --name gitlab-runner-01 -v /opt/gitlab-runner-01/config:/etc/gitlab-runner gitlab/gitlab-runner:v12.6.0
[root@localhost ~]# docker exec -it gitlab-runner-01 bash
[root@localhost ~]# gitlab-runner register --non-interactive --executor "shell" --url "http://192.168.66.222" --registration-token "oQMz4sA3WgB7LaGSaZvH" --description "gitlab-runner-01" --tag-list "build" --run-untagged="true" --locked="false" --access-level="not_protected"
效果:出現(xiàn)gitlabrunner了
