五、docker 安装gitlab与使用

本文档详细介绍了如何在Docker环境下安装GitLab,并配置外部访问URL及SSH端口。通过提供的步骤,可以获取初始管理员密码并成功登录。此外,还阐述了如何生成个人访问令牌,并使用HTTP模式从GitLab拉取代码到本地IDE的完整流程。
摘要由CSDN通过智能技术生成

一,安装

1、docker 安装

前提是上节已经装好docker-compose

换成自己的ip

[root@node2 ~] mkdir gitlab 
[root@node2 gitlab] cd gitlab
[root@node2 gitlab] vim docker-compose.yml

version: '3.1'
services:
  gitlab:
    image: 'gitlab/gitlab-ce:latest'
    container_name: gitlab
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://192.168.11.11:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
      - '8929:8929'
      - '2224:2224'
    volumes:
      - './config:/etc/gitlab'
      - './logs:/var/log/gitlab'
      - './data:/var/opt/gitlab'

2.安装

[root@node2 gitlab] docker-compose up -d

3.查看密码:

[root@node2 gitlab] docker exec -it gitlab cat /etc/gitlab/initial_root_password
[root@node2 gitlab]# docker exec -it gitlab cat /etc/gitlab/initial_root_password
# 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: Lwj/TwtfIVAt9qzDrr8TEdp8e0ch5TFLxUPDqw4IXIE=

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

4.登录:

地址:http://192.168.11.11:8929
用户为:root
密码:Lwj/TwtfIVAt9qzDrr8TEdp8e0ch5TFLxUPDqw4IXIE=

二、使用

1.从gitlab拉代码到本地(http模式)

1.1、创建个人令牌,记得保存,如生成我自己的:d_xAdf7KusJGDn43HHcQ,过程如下

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.2 拉取代码

1.2.1 获取clone链接(http模式,不是ssh模式)

在这里插入图片描述

1.2.2 拉取代码链接格式为:

  • 说明:只是复制以上的地址链接是拉取不到代码的,毕竟是私人仓库还要认证,所以要对以上的地址改装为已经认证的地址,让它在任何的idea上都可以拉取代码

  • 格式:http://用户名:token@+http地址

  • 综上就获得我们的拉取代码实际的链接:

http://guyusi:d_xAdf7KusJGDn43HhcQ@47.112.155.60:8929/root/devops.git

1.2.3 在idea中获取代码:

在这里插入图片描述
在这里插入图片描述
以上就可以拉去代码了

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值