ubuntu

ubuntu中gitlab如何更新

小樊
41
2025-07-03 21:04:02
栏目: 智能运维

在Ubuntu系统中更新GitLab,您可以选择使用官方推荐的包管理器(APT)或者Docker。以下是详细的更新步骤:

使用APT更新GitLab

  1. 添加GitLab官方GPG密钥和软件源

    curl https://packages.gitlab.com/gpg.key | sudo apt-key add -
    sudo sh -c 'echo "deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/gitlab.list'
    
  2. 更新系统软件包列表

    sudo apt-get update
    
  3. 检查可用的GitLab版本

    apt-cache madison gitlab-ce
    
  4. 升级GitLab

    sudo apt-get install gitlab-ce=<new-version>
    

    <new-version> 替换为您要安装的GitLab版本号。

  5. 重启GitLab服务

    sudo gitlab-ctl reconfigure
    sudo gitlab-ctl restart
    

使用Docker更新GitLab

  1. 拉取最新的GitLab镜像

    docker pull gitlab/gitlab-ce:latest
    
  2. 停止并删除当前的GitLab容器

    docker stop gitlab
    docker rm gitlab
    
  3. 使用最新的镜像重新创建并启动GitLab容器

    docker run --detach \
      --hostname <your-hostname> \
      --publish 443:443 --publish 80:80 --publish 22:22 \
      --name gitlab \
      --restart always \
      --volume /srv/gitlab/config:/etc/gitlab \
      --volume /srv/gitlab/logs:/var/log/gitlab \
      --volume /srv/gitlab/data:/var/opt/gitlab \
      gitlab/gitlab-ce:latest
    

    <your-hostname> 替换为您的GitLab主机名。

0
看了该问题的人还看了