1.进入容器

docker exec -it gitlab exec 

2.修改密码

su git
gitlab-rails console -e production //可以带上-e 参数查看版本,不同版本修改用户密码有细微差别
u = User.where(id:1).first
u.password='Qwer@1234'
u.save

[root@DevOPS ~]# docker exec -it gitlab bash
root@a36744b0240c:/# su git
$ gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
 GitLab:       14.0.0 (f1926d2aa64) FOSS
 GitLab Shell: 13.19.0
 PostgreSQL:   12.6
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.3.2)
irb(main):001:0> u = User.where(id:1).first
=> #<User id:1 @yuqiao>
irb(main):002:0> u.password='Qwer@1234'
=> "Qwer@1234"
irb(main):003:0> u.save
Enqueued ActionMailer::MailDeliveryJob (Job ID: d23bd315-a6cc-4f21-8c73-6890a1b39d82) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007ff1860ebdf0 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true
irb(main):004:0> 

3.重新登陆验证