docker-gitlab icon indicating copy to clipboard operation
docker-gitlab copied to clipboard

Reset Root Password

Open msmarino opened this issue 10 years ago • 10 comments

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.

msmarino avatar Oct 15 '16 00:10 msmarino

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.

xmik avatar Oct 15 '16 12:10 xmik

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 avatar Oct 15 '16 13:10 msmarino

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

solidnerd avatar Oct 16 '16 10:10 solidnerd

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...

msmarino avatar Oct 28 '16 06:10 msmarino

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 avatar Jun 06 '18 14:06 mhciael

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

pasake avatar Sep 11 '18 02:09 pasake

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)?

hcientist avatar Sep 11 '18 13:09 hcientist

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

mrsniperz avatar Dec 28 '18 07:12 mrsniperz

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

hannesa2 avatar Apr 18 '19 13:04 hannesa2

I leave a tutorial updated to the new version. In my case it is for a Gitlab installation on a Synology.

Translate (Spanish -> English ) https://translate.google.com/translate?sl=es&tl=en&u=https://www.vicolinker.net/synology-gitlab-reset-root-password/

Original (Spanish) https://www.vicolinker.net/synology-gitlab-reset-root-password/

victorelec14 avatar Jun 27 '21 14:06 victorelec14