环境
centos 7
docker
安装gitlab
下载镜像
╰─# docker pull gitlab/gitlab-ce:latest
启动gitlab
docker run -d -p 8443:433 -p 18080:18080 -p 8222:22 --name gitlab --restart always -v /srv/gitlab/config:/etc/gitlab -v /srv/gitlab/logs:/var/log/gitlab -v /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest
编辑gitlab的config:
编辑站点:
docker exec -it gitlab bash 进入gitlab容器中 vim /etc/gitlab.rb # 编辑站点地址, 如下图示 gitlab-ctl reconfigure # ,在容器中,使配置生效
退出容器, 重启gitlab容器
docker restart gitlab
查看gitlab的root的初始化密码
╰─# cat /srv/gitlab/config/initial_root_password # WARNING: This value is valid only in the following conditions # 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run). # 2. Password hasn't been changed manually, either via UI or via command line. # # If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password. Password: wkf4O0S3E21lPoo+AoNmJSlctuG+iZfCxLybdIlxogo= # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours. ╭─root@k202 /srv/gitlab/config ╰─#
注意:
/srv/gitlab/config : 此目录就是启动容器时,gitlab的config文件, 映射的主机的目录。
浏览器打开:http://192.168.10.202:18080/ 进行登录
用户名和密码: root/wkf4O0S3E21lPoo+AoNmJSlctuG+iZfCxLybdIlxogo=
登录成功以后,修改初始密码
注册gitlab-runner
下载gitlab-runner
╰─# docker pull gitlab/gitlab-runner:latest
启动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
注册runner
打开 Admin-area -> runner 点击注册一个新的runner,并拷贝token
将拷贝的token,作为以下命令行参数--registration-token的值:
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \ 1 ↵ --non-interactive \ --executor "docker" \ --docker-image alpine:latest \ --url "http://192.168.10.202:18080" \ --registration-token "zWZiV3hyCVk5bfJoi5RA" \ --description "docker-runner" \ --maintenance-note "Free-form maintainer notes about this runner" \ --tag-list "dockercicd,dev,java" \ --run-untagged="true" \ --locked="false" \ --access-level="not_protected"
--url "http://192.168.10.202:18080" \ : 该参数为gitlab的服务地址
--registration-token "zWZiV3hyCVk5bfJoi5RA" \ : 该参数为 gitalb的设置中的Admin - runner的toke值
输出一下结果,registration runner 成功
查看注册runner