接着http://www.cnblogs.com/wsy1030/p/8431837.html
在另一台机子运行gitlab:
docker run --name='gitlab' -d -p 2222:22 -p 80:80 --restart always --volume /data/gitlab/config:/etc/gitlab --volume /data/gitlab/logs:/var/log/gitlab --volume /data/gitlab/data:/var/opt/gitlab gitlab-ce
##--volume 相当于挂载,在服务器/data/gitlab/config目录和容器/etc/gitlab共享
/data/gitlab/logs和/var/log/gitlab共享,/data/gitlab/data和/var/opt/gitlab共享
gitlab-ce:镜像名称 本地没有的话会自动去网上下载,可以在仓库服务器下载完了打tag之后push到docker仓库里方便之后拓展使用
邮件提醒:
vi /data/gitlab/config/gitlab.rb
external_url 'http://192.168.110.22' ##访问gitlab的url
gitlab_rails['gitlab_ssh_host'] = '192.168.110.22' ##本机IP
gitlab_rails['gitlab_shell_ssh_port'] = 2222##本机ssh端口2222映射进gitlab22端口
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.legendtech.com" ##smtp服务器地址
gitlab_rails['smtp_port'] = 25 ##默认25
gitlab_rails['smtp_user_name'] = "[email protected]" #用户名
gitlab_rails['smtp_password'] = "####" #你的密码
gitlab_rails['smtp_domain'] = "[email protected]"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
重启:
docker restart gitlab
访问http://192.168.110.22就出现gitlab界面了
FAQ:
我也不知道初始默认密码~
重置gitlab的root密码:
获取PID
docker inspect -f {{.State.Pid}} c11897389ee2 ###CONTAINER ID 27792 ###容器名称c11897389ee2
进入容器
nsenter --target 27792 --mount --uts --ipc --net --pid
root@fc0581601dcf:/# gitlab-rails console production
Loading production environment (Rails 4.2.8)
irb(main):003:0* user = User.where(id: 1).first
=> #
irb(main):005:0> user.password=12345678
=> 12345678
irb(main):006:0> user.password_confirmation=12345678
=> 12345678
irb(main):007:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 0397ae9c-cbef-49ae-bdef-4951eae27854) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true
irb(main):008:0> quit
搭建runner
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | bash
yum -y install gitlab-ci-multi-runner
gitlab创建账户-项目-设置-CI/CD-赛跑者设置
如何为新项目设置一个特定的Runner
安装与GitLab CI兼容的运行程序(查看GitLab Runner部分以获取有关如何安装它的信息)。
在Runner设置期间指定以下URL: http://192.168.110.22/
在安装过程中使用以下注册令牌: FHNB1p_SBYMCr4VKErnT
开始跑步!
初始化5个runner:执行5次.或者添加到配置文件
gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.110.22/ ###输入访问gitlab的url 回车
Please enter the gitlab-ci token for this runner:
FHNB1p_SBYMCr4VKErnT ###输入注册令牌
Please enter the gitlab-ci description for this runner:
runner05 ###输入名字
Please enter the gitlab-ci tags for this runner (comma separated):
###打标记 我是默认什么都不输 回车
Whether to lock the Runner to current project [true/false]:
false ###输入false
Registering runner... succeeded runner=tULosrc8
Please enter the executor: parallels, ssh, docker+machine, kubernetes, docker, docker-ssh, shell, virtualbox, docker-ssh+machine:
docker ###输入docker
Please enter the default Docker image (e.g. ruby:2.1)
runner用的镜像 ###输入ruby:2.1
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
打开浏览器访问http://192.168.110.22/