docker 安裝請參考: docker - 環(huán)境搭建
服務(wù)搭建
# 獲取鏡像
docker pull gitlab/gitlab-ce
# 啟動容器
docker run -d \
--rm \
--restart always \
-u root \
--privileged \
--hostname domain.com \
--name gitlabCT \
-p 80:80 \
-v /root/gitlab/config:/etc/gitlab \
-v /root/gitlab/logs:/var/log/gitlab \
-v /root/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce
## 參數(shù)解釋
## -d 后臺運行, 如果容器無法正常運行, 可以去掉此項, 觀察報錯日志
## --rm 關(guān)閉容器時, 自動刪除容器
## --restart always - 使容器跟隨 docker 啟動 (開機, 重啟)
## -u root - 指定容器用戶
## --privileged - 授予容器特權(quán), 使用該參數(shù), container內(nèi)的root擁有真正的root權(quán)限, 否則, container內(nèi)的root只是外部的一個普通用戶權(quán)限渤弛。
## --hostname domain.com - 配置 gitlab 顯示的主機名
## -p ${local_port}:80 - 端口映射, 左邊是宿主機的監(jiān)聽端口, 80是 gitlab 在容器中的監(jiān)聽端口
## -v ${local_path}:${container_path} - 文件路徑映射, 左邊是本地路徑, 右邊是 gitlab 在容器中使用的路徑 (不要修改)
# 查看容器狀態(tài)
docker ps
# 結(jié)束運行
docker rm -f gitlabCT
web管理
初始用戶 root
以下設(shè)置均為個性化的需求, 僅供參考
- 關(guān)閉用戶注冊
Admin Area > Settings > Sign-up restrictions > Sign-up enabled
- 關(guān)閉 CI/CD pipline
Admin Area > Settings > CI/CD > Continuous Integration and Deployment > Default to Auto DevOps pipeline for all projects
- 關(guān)閉 ssh 訪問
Admin Area > Settings > General > Visibility and access controls > Enabled Git access protocols