美文网首页
如何在Ubuntu上使用docker compose搭建gitl

如何在Ubuntu上使用docker compose搭建gitl

作者: 想看烟花么 | 来源:发表于2024-01-22 21:45 被阅读0次

1.docker安装

  https://www.jianshu.com/p/ea9b201e8b59

2.使用docker-compose.yml搭建gitlab:

  -安装:https://docs.gitlab.com/ee/install/docker.html

3.安装gitlab:

https://docs.gitlab.com/ee/install/docker/installation.html

⚠️如果使用自定义端口请高仿:

#yml文件格式检测网址https://www.bejson.com/validators/yaml_editor/
#gitlab-ce-compose.yml
version: '3.6'
services:
  web:
    container_name: gitlab
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: 'gitlab.study.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
       #记住这里一定要带上端口否则gitlab项目clone地址也会没有端口导致gitlab-runner拉取不到项目,这里特意提示下
        external_url 'http://192.168.1.6:1080'
        # Add any other gitlab.rb configuration here, each on its own line
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['gitlab_ssh_host'] = '192.168.1.6'
        gitlab_rails['gitlab_shell_ssh_port'] = 1022
    ports:
      - '1080:1080'
      - '1443:443'
      - '1022:22'
    volumes:
      - './config:/etc/gitlab'
      - './logs:/var/log/gitlab'
      - './data:/var/opt/gitlab'
    shm_size: '256m'

命令行执行:

sudo docker-compose -f gitlab-ce-compose.yml up -d

#可能会报错:
ERROR: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
#解决方案(试了好多源都不行,终于):
#https://blog.csdn.net/Crime_man/article/details/143468533
sudo vi /etc/docker/daemon.json
{
    "registry-mirrors":[
            https://docker.rainbond.cc/
            https://docker.rainbond.com/
    ]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl docker info
sudo systemctl status docker

5.修改root首次登陆密码:

    查看容器gitlab状态:
    docker ps
    进入gitlab的容器中:
    docker exec -it(gitlab的容器名称或id) bash
    启动Ruby on Rails控制台,稍微要多等待一会:
    gitlab-rails console
    等待控制台加载完毕并找到root用户:
    user = User.where(id: 1).first
    或者
    user = User.find_by(email: 'admin@example.com')
    更改密码
    user.password = '你的密码'
    user.password_confirmation = '确认你的密码'
    保存更改
    user.save!
    退出:
    exit

4.成功:

image.png

5.配置域名访问:

image.png

---------------------End----------------------

相关文章

网友评论

      本文标题:如何在Ubuntu上使用docker compose搭建gitl

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