#1.安装gitlab
docker run -d -p 4433:443 -p 800:80 -p 222:22 --name gitlab --privileged=true --restart always -v /data/work/soft/gitlab/config:/etc/gitlab -v /data/work/soft/gitlab/logs:/var/log/gitlab -v /data/work/soft/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce
#2.修改gitlab.rb
[root@192 config]# pwd
/data/work/soft/gitlab/config
[root@192 config]# ll
总用量 184
-rw-------. 1 root root 303 3月 18 22:58 gitlab.rb
-rw-------. 1 root root 133742 3月 18 22:37 gitlab.rb.sample
-rw-------. 1 root root 19103 3月 18 22:56 gitlab-secrets.json
-rw-------. 1 root root 749 3月 18 22:37 initial_root_password
-rw-------. 1 root root 513 3月 18 22:37 ssh_host_ecdsa_key
-rw-r--r--. 1 root root 179 3月 18 22:37 ssh_host_ecdsa_key.pub
-rw-------. 1 root root 411 3月 18 22:37 ssh_host_ed25519_key
-rw-r--r--. 1 root root 99 3月 18 22:37 ssh_host_ed25519_key.pub
-rw-------. 1 root root 2602 3月 18 22:37 ssh_host_rsa_key
-rw-r--r--. 1 root root 571 3月 18 22:37 ssh_host_rsa_key.pub
drwxr-xr-x. 2 root root 6 3月 18 22:37 trusted-certs
[root@192 config]# cat gitlab.rb
# 配置http协议所使用的访问地址,不加端口号默认为80。注意:如果有自己的公网域名,那么也可以写自己的公网域名,这里的地址就是去访问公网域名用的
external_url 'http://192.168.3.109:800'
# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = '192.168.3.109'
gitlab_rails['gitlab_shell_ssh_port'] = 222 # 此端口是run时22端口映射的222端口
如果修改以上配置的话,那么就不用去修改../data/gitlab-rails/etc/gitlab.yml。因为执行顺序是先gitlab.yml,然后再gitlab.rb,这样的话,后面的会覆盖前面的。
#3.修改root初始密码
docker exec -it xx /bin/bash
gitlab-rails console -e production
user=User.where(id:1).first
user.password='xxxxxxxx'
user.password_confirmation='xxxxxxxx'
user.save!