使用docker搭建gitlab

使用docker搭建gitlab

在服務器上直接安裝gitlab,會裝入Git,Redis ,postgresql,nginx等。如果主機已有redis、nginx等,配置會比較麻煩。而且以後gitlab的備份和遷移都不方便。附主機安裝教程:

https://about.gitlab.com/downloads/#centos7
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

如果將gitlab進行Docker化部署,所有服務如redis,postgresql等放在一個docker容器裏,將配置、數據等文件掛載在宿主機上,備份和遷移時候只要複製docker鏡像和掛載的數據目錄即可。

運行gitlab容器

#查找鏡像
[root@cloud ~]# docker search gitlab


INDEX       NAME                                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/gitlab/gitlab-ce                         GitLab Community Edition docker image base...   946                  [OK]
docker.io   docker.io/sameersbn/gitlab                         Dockerized gitlab web server                    803                  [OK]
docker.io   docker.io/gitlab/gitlab-runner                                                                     143                  [OK]
docker.io   docker.io/gitlab/gitlab-ee                         GitLab Enterprise Edition docker image bas...   47                   
# 拉取鏡像
docker pull docker.io/gitlab/gitlab-ce

# 啓動鏡像(使用橋接網絡啓動docker)
docker run --name='gitlab-ce' -d \
       --net=none \
       --restart always \
       --volume /home/gitlab/config:/etc/gitlab \
       --volume /home/gitlab/logs:/var/log/gitlab \
       --volume /home/gitlab/data:/var/opt/gitlab \
       gitlab/gitlab-ce

# 設置網絡IP
pipework br0 gitlab-ce 132.97.8.10/24@132.97.8.1

配置gitlab服務器的訪問地址

修改gitlab的配置文件
vi /home/gitlab/config/gitlab.rb

# 配置http協議所使用的訪問地址
external_url 'http://132.97.xxx.xxx'

修改gitlab.rb配置文件之後,重啓容器。或者在容器裏執行gitlab-ctl reconfigure命令。

# 進入容器
docker exec -it gitlab-ce  bash

# 重啓gitlab
gitlab-ctl reconfigure

瀏覽器打開http://132.97.xxx.xxx即可訪問到gitlab

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章