Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

763
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda