Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

761
Views
How do I start a gitlab-ce container via docker-compose with admin credentials already set up?

I have a docker-compose.yml file with a Gitlab CE container:

services:
  // other services..
  gitlab:
    image: 'gitlab/gitlab-ce'
    restart: always
    ports:
      - '80:80'
      - '443:443'
      - '22:22'
      - "127.0.0.1:8081:80"
    volumes:
      - '/etc/gitlab'
      - '/var/log/gitlab'
      - '/var/opt/gitlab'
    networks:
      - backend

On startup, this requires you to open the browser, go to(in this case) localhost:8081 and manually input a password.

I'd like for this process to be automated(for local development and testing purposes).

Gitlab's own answers:

    gitlab-rails console production
    user = User.where(id: 1).first
    user.password = 'somethingsomething'
    user.password_confirmation = 'somethingsomething'
    user.save!
    exit

Which works if I ssh into the Gitlab CE container after everything is set up(takes minutes).

Running this directly via command does not work - presumably because the gitlab-rails console isn't ready to go yet the minute the container is up.

I've tried to manually create a Dockerfile with the gitlab/gitlab-ce image, used COPY to get the above script into the container and CMD it. However, as predicted, this fails as gitlab-rails console isn't ready yet on start-up. It takes a while.

Ideal scenario is that the container starts, installs Gitlab and does all the setup stuff; then sets the root admin password automatically.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The solution is to set the GITLAB_OMNIBUS_CONFIG as an environment variable.

This works:

services:
  // other services..
  gitlab:
    image: 'gitlab/gitlab-ce'
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['initial_root_password'] = 'adminadmin'
    ports:
      - '80:80'
      - '443:443'
      - '22:22'
      - "127.0.0.1:8081:80"
    volumes:
      - '/etc/gitlab'
      - '/var/log/gitlab'
      - '/var/opt/gitlab'
    networks:
      - backend

When starting up the service, this is confirmed:

gitlab_1       |               == Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/002_admin.rb
gitlab_1       |               Administrator account created:
gitlab_1       |               
gitlab_1       |               login:    root
gitlab_1       |               password: adminadmin
over 4 years ago · Santiago Trujillo Report

0

This is how I fixed this issue on my side:

sudo docker exec -it container_name bash
// replace username by your user, for me it is root
gitlab-rake "gitlab:password:reset[username]"
over 4 years ago · Santiago Trujillo Report

0

I try the cbll response but doesnt work for me.

To change the root password manually in Docker Container Gitlab CE.

  1. docker exec -it <git_lab_container> bash
  2. gitlab-rails console

-----Wait until the console open----

  1. irb(main):001:0> user = User.find_by_username 'root'

  2. irb(main):001:0> user.password = "newpassword"

  3. irb(main):001:0> user.confirmation_password = "newpassword"

  4. irb(main):001:0> user.save!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!