笔记笔记
  • Home
  • AI&ML
  • Example
  • Zoo
  • 关于
⌘ K
docker 笔记
常用容器
Sonatype Nexus
GitLab CE
BitTorrent Tracker
搜索引擎
Debian
最后更新时间:
Copyright © 2023-2024 | Powered by dumi | GuoDapeng | 冀ICP备20004032号-1 | 冀公网安备 冀公网安备 13024002000293号

TABLE OF CONTENTS

‌
‌
‌
‌

GitLab Community Edition

官方文档

部署脚本

## 下载特定版本镜像
docker pull gitlab/gitlab-ce:17.9.0-ce.0
## 删除容器和镜像
docker stop gitlab-ce && docker rm gitlab-ce
## 启动容器,并且在后台运行
mkdir config logs data
docker run --detach \
--hostname 127.0.0.1 \
--publish 8080:80 \
--publish 8022:22 \
--restart always \
--name gitlab-ce \
--volume $PWD/config:/etc/gitlab \
--volume $PWD/logs:/var/log/gitlab \
--volume $PWD/data:/var/opt/gitlab \
gitlab/gitlab-ce:17.9.0-ce.0

启动之后,默认用户名 admin@example.com。容器内可以查看初始密码。

cat /etc/gitlab/initial_root_password

备份

在版本升级的时候,有时候莫名其妙的就是无法升级成功,老是自己重启,这时候可以考虑试试备份,创建新的容器,用备份还原试试。 先在能启动的版本启动起来,进行备份,创建新的容器,进行还原。

## 备份数据
gitlab-rake gitlab:backup:create
# 恢复 这里注意,不是完整的备份文件名,而是文件名去掉_gitlab_backup.tar后缀
cd /var/opt/gitlab/backups
gitlab-rake gitlab:backup:restore BACKUP=1696921538_2023_10_10_16.1.5
## 拷贝备份数据的例子
docker cp ./backup.tar gitlab-ce-13.4:/var/opt/gitlab/backups/backup.tar

SSH 密钥

SSH 密钥

常用命令

docker logs -f gitlab-ce
docker exec -it gitlab-ce /bin/bash
# 重新应用gitlab的配置
gitlab-ctl reconfigure
# 重启gitlab服务
gitlab-ctl restart
# 查看gitlab运行状态
gitlab-ctl status
#停止gitlab服务
gitlab-ctl stop
# 查看gitlab运行日志
gitlab-ctl tail

常见问题

仓库权限问题

升级时,出现如下错误:

23:34:37.236: [doc] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false fetch origin --recurse-submodules=no --progress --prune
fatal: detected dubious ownership in repository at '/var/opt/gitlab/git-data/repositories/@hashed/81/17/811786ad1ae74adfdd20dd0372abaaebc6246e343aebd01da0bfc4c02bf0106c.git'
To add an exception for this directory, call:
git config --global --add safe.directory /var/opt/gitlab/git-data/repositories/@hashed/81/17/811786ad1ae74adfdd20dd0372abaaebc6246e343aebd01da0bfc4c02bf0106c.git
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

可以进入容器查看:

root@127:/var/opt/gitlab/git-data/repositories/@hashed/81/17/811786ad1ae74adfdd20dd0372abaaebc6246e343aebd01da0bfc4c02bf0106c.git# ls -lh
total 12K
---------- 1 1026 users 21 Jul 6 2023 HEAD
---------- 1 1026 users 66 Jul 6 2023 config
---------- 1 1026 users 344 Jul 28 06:31 gitaly-language.stats
d--------- 1 1026 users 0 Mar 31 04:52 info
d--------- 1 1026 users 16 Aug 7 14:23 objects
d--------- 1 1026 users 32 Aug 29 2023 refs

这里用户和用户组是错的,需要修改一下。 可以使用以下命令修改:

# 修改 repositories 用户和用户组
cd /var/opt/gitlab/git-data
chown -R git:git *
Preview