文章插圖

文章插圖
環境介紹:
192.168.2.20
Node2、Gitlab
CentOS 7.5.1804
Docker 19.03.13
2核+CPU,4GB+內存(Gitlab低于4G內存會報502錯誤)
部署Gitlab倉庫:
– 拉取Gitlab鏡像
[[email protected] ~]# docker pull gitlab/gitlab-ceUsing default tag: latestlatest: Pulling from gitlab/gitlab-ce35807b77a593: Pull completeb32ac5d80a55: Pull completedf336912e872: Pull completeb793eccd1af3: Pull completef74a7e006150: Pull complete0084a219e293: Pull complete3af13cab3fdf: Pull complete59278f51bfcb: Pull completeDigest: sha256:7241af5bd54251aa412692cff1adf2d8c604425a03adad5300919b06bd4c6585Status: Downloaded newer image for gitlab/gitlab-ce:latestdocker.io/gitlab/gitlab-ce:latest[[email protected] ~]# docker imagesREPOSITORYTAGIMAGE IDCREATEDSIZEgitlab/gitlab-celatestca616a263319Less than a second ago2.29GB– 運行Gitlab容器命令解釋:
-i :以交互模式運行容器,通常與 -t 同時使用命令解釋-t :為容器重新分配一個偽輸入終端,通常與 -i 同時使用-d :后臺運行容器,并返回容器ID-p:80:80 將容器內80端口映射至宿主機80端口,這是訪問gitlab的端口-p:222:22 將容器內22端口映射至宿主機222端口,這是訪問ssh的端口-v :/usr/local/gitlab-test/etc:/etc/gitlab 將容器/etc/gitlab目錄掛載到宿主機/usr/local/gitlab-test/etc目錄下,若宿主機內此目錄不存在將會自動創建,其他兩個掛載同這個一樣–restart always :容器自啟動–privileged=true :讓容器獲取宿主機root權限–name gitlab :設置容器名稱為gitlabgitlab/gitlab-ce :鏡像的名稱,這里也可以寫鏡像ID
[[email protected] ~]# docker run -itd --name gitlab -p 443:443 -p 80:80 -p 222:22 --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce971e942b7a703fb82bcd308a3ad8c0f70912ea7abb14b46e8c63ca5b82ab6568docker run -v掛載目錄時,若本地沒有該目錄掛載時會自動創建 。[[email protected] ~]# ls /home/gitlab[[email protected] ~]# ls /home/gitlab/configdatalogs[[email protected] ~]# docker psCONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES971e942b7a70gitlab/gitlab-ce"/assets/wrapper"About a minute agoUp About a minute (health: starting)0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:222->22/tcpgitlab– 修改gitlab.rb配置文件注意:
?修改gitlab.rb配置文件操作最好是在容器內進行修改(也可以在宿主機映射目錄中修改,記得修改完后進入容器驗證修改結果),在掛載到宿主機的文件上直接進行修改可能會出現配置更新不到容器內,或者是不能即時更新到容器內,導致gitlab啟動成功,但是無法訪問或其它問題 。
[[email protected] ~]# vim /home/gitlab/config/gitlab.rb//gitlab.rb文件內容默認全部注釋......32 # external_url 'GENERATED_EXTERNAL_URL'33 external_url 'http://192.168.1.20'//配置http協議所使用的gitlab訪問地址,可以寫域名 。如果端口不寫的話默認為80端口34 gitlab_rails['gitlab_ssh_host'] = '192.168.1.20'//配置ssh協議所使用的訪問地址和端口35 gitlab_rails['gitlab_shell_ssh_port'] = 222//此端口是docker run時22端口映射的222端口36 ## Roles for multi-instance GitLab原始內存大小:
[[email protected] ~]# free -htotalusedfreesharedbuff/cacheavailableMem:1.9G342M482M14M1.1G1.3GSwap:0B0B0B升級后內存大?。?br />
[[email protected] ~]# free -htotalusedfreesharedbuff/cacheavailableMem:3.8G2.9G157M25M821M613MSwap:0B0B0B訪問:登錄Gitlab倉庫:
?Gitlab默認的管理員臨時密碼在gitlab容器中/etc/gitlab/initial_root_password文件中,如果該路徑下沒有這個文件,我們就無法正常登錄到gitlab中去,可以試試下面兩種方法 。
1.宿主機中搜索initial_root_password文件
[[email protected] ~]# find / -name initial_root_password/mnt/data/volumes/e7d5b220d1dc98ea2229882865f58e643fef42d4f1c16a3a54458abd017b7c77/_data/initial_root_password[[email protected] ~]# cat /mnt/data/volumes/e7d5b220d1dc98ea2229882865f58e643fef42d4f1c16a3a54458abd017b7c77/_data/initial_root_password# WARNING: This value is valid only in the following conditions#1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).#2. Password hasn't been changed manually, either via UI or via command line.##If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.Password: LkhENj02qgKkT7DZplqE35TfdPThK3wuSCgHw0H+BOI=# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.?可以看到上面搜索到的initial_root_password文件中顯示了gitlab的默認密碼 。2.重置gitlab管理員賬戶密碼
?5分鐘帶你重置Gitlab管理員賬戶密碼:https://blog.csdn.net/qq_44895681/article/details/120530904?spm=1001.2014.3001.5501
- steam找回密碼支付卡類型那個是微信 steam賬號找回支付卡類型
- 蘋果手機如何刷機解鎖密碼 蘋果手機密碼鎖了怎么刷機
- 電腦文件夾加密碼怎么設置密碼 電腦文件夾加密碼怎么設置
- 手機開機密碼忘記了怎么辦 筆記本開機密碼忘記了怎么辦
- 魅族手機忘記鎖屏密碼10秒解決 魅族忘記手機密碼怎么辦?10秒教你解開屏幕鎖
- 蘋果忘記id密碼怎么找回手機 蘋果忘記id密碼怎么找回綁定的手機號是以前的
- win10更改hosts無法保存 window10修改hosts無法保存
- pdf設置密碼怎么破解 PDF密碼怎么破解
- adsl賬號密碼在哪里可以查看 adsl賬戶密碼查詢
- 軟件如何解密 軟件解密碼
