- 进入gitlab容器执行gitlab-rails console production,命令:
docker exec -it gitlab-web-1 gitlab-rails console production
root@DESKTOP-1T50PP8:/srv/gitlab/config# docker exec -it gitlab-web-1 gitlab-rails console production
-------------------------------------------------------------------------------------
GitLab: 12.0.2 (1a9fd38a4ca)
GitLab Shell: 9.3.0
PostgreSQL: 10.7
-------------------------------------------------------------------------------------
Loading production environment (Rails 5.1.7)
- 选择root用户,一般id为1,赋值给user变量
irb(main):004:0> user=User.where(id:1).first
=> #<User id:1 @root>
- 修改和确认密码
irb(main):005:0> user.password='rt123456'
=> "rt123456"
irb(main):006:0> user.password_confirmation='rt123456'
=> "rt123456"
- 改成激活状态
irb(main):011:0> user.state='active'
- 保存更改
irb(main):007:0> user.save!
=> true
- 此时可以以root, rt123456登录gitlab。