Skip to content

docker 升级 gitlab

Published: at 20:00

书接上文

gitlab 服务搭建小记

说明:本文方法只适用于自己使用 docker 搭建 gitlab 试用的场景,仅供参考,不能作为运维方案

背景

当前 docker 部署的 gitlab 版本是 17.2,使用时提示升级。

目标是升级到 17.4 版本

操作

因为不能跨版本升级,需要先升级到 17.3 版本,所以先拉取如下两个镜像

Terminal window
docker pull gitlab/gitlab-ce:17.3.4-ce.0
docker pull gitlab/gitlab-ce:17.4.1-ce.0

备份

之前容器启动命令如下,可以看到数据都在 E:/docker/volume/gitlab 这个目录。

先 stop 当前正在运行的容器,然后备份整个目录

Terminal window
docker run --detach \
--hostname gitlab.xxx.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.xxx.com'" \
--publish 50443:443 --publish 50080:80 --publish 50022:22 \
--name gitlab \
--restart always \
--volume E:/docker/volume/gitlab/config:/etc/gitlab:Z \
--volume E:/docker/volume/gitlab/logs:/var/log/gitlab:Z \
--volume E:/docker/volume/gitlab/data:/var/opt/gitlab:Z \
--shm-size 2g \
gitlab/gitlab-ce:latest

启动 17.3.4 版本的容器

Terminal window
docker run --detach \
--hostname gitlab.xxx.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.xxx.com'" \
--publish 50443:443 --publish 50080:80 --publish 50022:22 \
--name gitlab17.3.4 \
--restart always \
--volume E:/docker/volume/gitlab/config:/etc/gitlab:Z \
--volume E:/docker/volume/gitlab/logs:/var/log/gitlab:Z \
--volume E:/docker/volume/gitlab/data:/var/opt/gitlab:Z \
--shm-size 2g \
gitlab/gitlab-ce:17.3.4-ce.0

如果一切正常,等待几分钟之后,gitlab 就可以正常使用了。

此时 stop 17.3.4 的容器,启动 17.4.1 的容器

Terminal window
docker run --detach \
--hostname gitlab.xxx.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.xxx.com'" \
--publish 50443:443 --publish 50080:80 --publish 50022:22 \
--name gitlab17.4.1 \
--restart always \
--volume E:/docker/volume/gitlab/config:/etc/gitlab:Z \
--volume E:/docker/volume/gitlab/logs:/var/log/gitlab:Z \
--volume E:/docker/volume/gitlab/data:/var/opt/gitlab:Z \
--shm-size 2g \
gitlab/gitlab-ce:17.4.1-ce.0

等待几分钟,如果一切正常,就完成升级了

就这样


原文链接: https://blog.jgrass.cc/posts/upgrade-docker-gitlab/

本作品采用 「署名 4.0 国际」 许可协议进行许可,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。