Docker-compose搭建Git私服

1. 新建个专用的目录,然后在里面新建个docker-compose.yml文件:

(gitlab-ce是社区版,当然还有ee,是商业版)

version: '3.6'                                                                                                                                                                                                                                                                                                                                                                                                                                                     
services:                                                                                                                                                                                                                                 
  web:                                                                                                                                                                                                                                    
    image: 'gitlab/gitlab-ce:latest'                                                                                                                                                                                                      
    restart: always                                                                                                                                                                                                                       
    hostname: 'gitlab.example.com'                                                                                                                                                                                                        
    environment:                                                                                                                                                                                                                          
      GITLAB_OMNIBUS_CONFIG: |                                                                                                                                                                                                            
        external_url 'https://你的公网IP:30080'                                                                                                                                                                                        
        # Add any other gitlab.rb configuration here, each on its own line                                                                                                                                                                
    ports:                                                                                                                                                                                                                                
      - '30080:30080'                                                                                                                                                                                                                     
      - '30443:443'                                                                                                                                                                                                                       
      - '30022:22'                                                                                                                                                                                                                        
      - '3080:80'                                                                                                                                                                                                                         
    volumes:                                                                                                                                                                                                                              
      - './config:/config:/etc/gitlab'                                                                                                                                                                                                    
      - './logs:/logs:/var/log/gitlab'                                                                                                                                                                                                    
      - './data:/data:/var/opt/gitlab'                                                                                                                                                                                                    
    shm_size: '256m'                                                                                                                                                                                                                      

2. 启动docker-compose,并检查语法:

docker compose up -d

3. 进入容器,之后查看密码

cat /etc/gitlab/initial_root_password

输出的结果是:

首先这里面告诉了我们初始 username为root,密码是 QKHN+xn7H2s/FvyIQ8ZqAqVBkTufEEs4eJXyrxi3FyM=,但是这个文件会在24小时内自动删除,所以最好还是按照提示去重置一下密码。

# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: QKHN+xn7H2s/FvyIQ8ZqAqVBkTufEEs4eJXyrxi3FyM=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

 如果你不想重置密码,直接访问 https://你的公网IP:30080,然后输入初始用户名和密码就可以了。

4. 重置密码

还是访问 https://你的公网IP:30080,然后在左边的侧边栏点击向下的箭头,然后选择【Admin Area】-【Overview】-【Users】,然后修改。密码要求数字+字母,至少8位。

(所以我为什么不直接在DockerCompose文件里面直接设置密码(〃>皿<))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值