一智绸、修改 docker 鏡像源為國內(nèi)源
# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://lvpmz2sk.mirror.aliyuncs.com"]
}
systemctl reload docker #修改完成后重新載入docker服務(wù)
二凄贩、使用 docker-compose 管理 gitlab 和 gitlab-runner 容器鏡像
# vi docker-compose.yml
version: '2'
services:
gitlab:
image: gitlab/gitlab-ce:11.0.0-ce.0
restart: always
hostname: gitlab
container_name: gitlab
ports:
- 80:80
volumes:
- /etc/localtime:/etc/localtime
- ./conf:/etc/gitlab
- ./data/logs:/var/log/gitlab
- ./data/data:/var/opt/gitlab
gitlab-runner:
image: gitlab/gitlab-runner
restart: always
hostname: gitlab-runner
container_name: gitlab-runner
extra_hosts:
- git.imlcs.top:192.168.88.167
depends_on:
- gitlab
volumes:
- /etc/localtime:/etc/localtime
- ./runner:/etc/gitlab-runner
目錄結(jié)構(gòu)
安裝過程中遇到的問題:
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system Configuring GitLab package... Configuring GitLab...
解決方法:
chmod 2770 data/data/git-data/repositories
docker-compose down
docker-compose up -d(初次創(chuàng)建時 gitlab 啟動很慢刺下,估計需要十幾分鐘左右)
三染乌、gitlab 成功啟動后連接到 gitlab-runner 配置 gitlab 的 gitlab-runner
docker-compose exec gitlab-runner sh # 連接進入 gitlab-runner 容器
gitlab-runner register # 進入容器后執(zhí)行的命令
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://git.imlcs.top # gitlab 的訪問路徑
Please enter the gitlab-ci token for this runner:
JLP2Rk2qcUZEfs_WLrTv # 注冊令牌鉴扫,在 gitlab 中獲取
Please enter the gitlab-ci description for this runner:
[gitlab-runner]: test_runner # runner 的名字
Please enter the gitlab-ci tags for this runner (comma separated):
test # runner 的 tag
Registering runner... succeeded runner=JLP2Rk2q
Please enter the executor: docker-ssh, parallels, docker+machine, docker-ssh+machine, docker, shell, ssh, virtualbox, kubernetes:
docker # 使用 docker 作為輸出模式
Please enter the default Docker image (e.g. ruby:2.1):
alpine:latest # 使用的基礎(chǔ)鏡像
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
############################# 注冊成功后會顯示以上信息狞贱,然后執(zhí)行下面的命令進行啟動 ###################################
gitlab-runner start # 啟動該 runner
使用 root 用戶登錄 gitlab 后獲取令牌
注冊成功后會顯示的runner的信息