美文网首页
docker-compose跑gitlab,gitlab初始化账

docker-compose跑gitlab,gitlab初始化账

作者: 风吹路过的云 | 来源:发表于2021-07-06 21:56 被阅读0次

    docker-compose跑gitlab,docker-compose.yml文件如下:

    
    version: '3'
    services:
        gitlab-ce:
            image: gitlab/gitlab-ce
            container_name: gitlab-ce
            network_mode: bridge
            restart: always
            tty: true
            hostname: gitlab.dev.local
            ports: 
              - 80:80
              - 443:443
            environment:
                TZ: "Asia/Shanghai"
                GITLAB_OMNIBUS_CONFIG: |
                    external_url "http://gitlab.dev.local"
                    postgresql['shared_buffers'] = "256MB"
                    sidekiq['concurrency'] = 4
                    prometheus_monitoring['enable'] = false
            volumes:
                - /data/gitlab/ce/config:/etc/gitlab
                - /data/gitlab/ce/logs:/var/log/gitlab
                - /data/gitlab/ce/data:/var/opt/gitlab
    
    

    把gitlab跑起来,查看当前容器状况

    CONTAINER ID   NAMES                              STATUS                           PORTS                                                                              IMAGE
    db60d2386cff   gitlab-ce                          Up 36 minutes (healthy)          0.0.0.0:80->80/tcp, :::80->80/tcp, 22/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   gitlab/gitlab-ce
    

    这时,gitlab已经跑起来了,通过浏览器能正常访问了,那么问题来了,初始化的管理员账号是什么呢?是root,那它的密码是什么呢?
    我也不知道它的密码是多少,进容器里修改root的密码
    1 进入容器
    2 进入gitlab的bin目录

    cd /opt/gitlab/bin
    

    3 执行gitlab-rails console

    root@gitlab:/opt/gitlab/bin# gitlab-rails console
    --------------------------------------------------------------------------------
     Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
     GitLab:       14.0.2 (bac4ee4a9e2) FOSS
     GitLab Shell: 13.19.0
     PostgreSQL:   12.6
    --------------------------------------------------------------------------------
    Loading production environment (Rails 6.1.3.2)
    irb(main):001:0>
    

    4 找到root的用户,输入u=User.where(id:1).first,然后回车

    irb(main):001:0> u=User.where(id:1).first
    => #<User id:1 @root>
    

    5 修改password,输入u.password='12345678',然后回车

    irb(main):002:0> u.password='12345678'
    => "12345678"
    

    6 修改确认密码

    irb(main):004:0> u.password_confirmation='12345678'
    => "12345678"
    

    7 保存修改,输入u.save,然后回车,等到输出true,这时,密码修改成功。

    irb(main):005:0> u.save
    Enqueued ActionMailer::MailDeliveryJob (Job ID: d4c64606-0597-46ae-a7b5-fa9bb01c2685) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007fe59ae70c98 @uri=#<URI::GID gid://gitlab/User/1>>]}
    => true
    

    至此,密码修改成功,可以用12345678密码登录进去了

    相关文章

      网友评论

          本文标题:docker-compose跑gitlab,gitlab初始化账

          本文链接:https://www.haomeiwen.com/subject/ntlnultx.html