Docker-gitlab: Reset Root Password

Created on 15 Oct 2016  路  9Comments  路  Source: sameersbn/docker-gitlab

I am running gitlab from default docker-compose script and need to reset the root password...

Gitlab docs say
gitlab-rails console production
but I get
bash: gitlab-rails: command not found

Alternatively, here I found
sudo -u git -H bundle exec rails console production
but I get
Rails Error: Unable to access log file. Please ensure that /home/git/gitlab/log/production.log exists and is writable (ie, make it writable for user and group: chmod 0664 /home/git/gitlab/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
/home/git/gitlab/config/initializers/6_validations.rb:6:in 'realpath': No such file or directory @ realpath_rec - /home/git/repositories (Errno::ENOENT)

The log 'folder' is a link to an inexistant folder, but that isn't the critical error.

I also found #904 suggesting setting up GITLAB_ROOT_PASSWORD and running
bin/rake gitlab:setup
but get the same error...

Tried 8.12.4 & 8.12.5

Any and all help appreciated.

Most helpful comment

IF anyone else lands here (like I did) looking to reset their password, try ( https://github.com/sameersbn/docker-gitlab/issues/916#issuecomment-395078678 ):

  1. docker exec -it GITLAB_CONTAINER_ID /bin/bash
  2. su - git
  3. cd gitlab
  4. bundle exec rails c production
  5. user = User.where(id: 1).first
  6. user.password = 'NEW_PASS'
  7. user.password_confirmation = 'NEW_PASS'
  8. user.save
  9. exit

All 9 comments

I had this problem yesterday. I succeeded in setting custom gitlab root password with GITLAB_ROOT_PASSWORD (it must be >= 8 characters long) and then run in gitlab container as git user: bundle exec rake gitlab:setup RAILS_ENV=production.

Thx for the reply!!

Unfortunately when I run
docker-compose exec gitlab sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
it asks for confirmation and wipes out the whole database!
And with
docker-compose exec gitlab sudo -u git -H bundle exec rake gitlab:setup production
I get
D, [2016-10-15T14:42:02.656332 #549] DEBUG -- sentry: ** [Raven] cannot load such file -- haml_lint/rake_task excluded from capture due to environment or should_capture callback rake aborted!

As you cas see, rails is NOT my thing.

@msmarino Which database do you use ? MySQL or Postgresql ?

I am using postgresql as as defined in the docker-compose.yml.

Finally I used virtualbox to install a 'full' version and imported/changed/exported my data without a hitch. Then reimported back to my docker instance. Not optimal but a solution...

IF anyone else lands here (like I did) looking to reset their password, try ( https://github.com/sameersbn/docker-gitlab/issues/916#issuecomment-395078678 ):

  1. docker exec -it GITLAB_CONTAINER_ID /bin/bash
  2. su - git
  3. cd gitlab
  4. bundle exec rails c production
  5. user = User.where(id: 1).first
  6. user.password = 'NEW_PASS'
  7. user.password_confirmation = 'NEW_PASS'
  8. user.save
  9. exit

@mhciael hi,i follow your method but
image
Is there a problem with my installation?

perhaps you're doing this before you have completed the gitlab install? Like when you first visit it they would create the admin user i think? what error is missing in the above (truncated at top of screenshot)?

@mhciael Thanks a lot ,it works!!and you can check all the ID with:user = Use.all,because you may not the No.1.

I was able that way:
search for your Docker CONTAINER_ID
docker ps -all

eg
image

docker exec -it d0bbe0e1e3db bash <-- with your CONTAINER_ID
$ gitlab-rails console production
image
user = User.where(id: 1).first
user.password = 'your secret'
user.password_confirmation = 'your secret'
user.save
exit
exit

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martinspaeth picture martinspaeth  路  3Comments

Daxten picture Daxten  路  4Comments

globalcitizen picture globalcitizen  路  4Comments

lenovouser picture lenovouser  路  3Comments

cyklodev picture cyklodev  路  3Comments