1. 程式人生 > >Centos7:Docker安裝Gitlab

Centos7:Docker安裝Gitlab

[[email protected] ~]# docker search gitlab 
INDEX       NAME                                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/gitlab/gitlab-ce                             GitLab Community Edition docker image base...   1784
[OK] docker.io docker.io/sameersbn/gitlab Dockerized gitlab web server 1022 [OK] docker.io docker.io/gitlab/gitlab-runner GitLab CI Multi Runner used to fetch and r... 311 [OK] docker.io
docker.io/twang2218/gitlab-ce-zh 漢化的 GitLab 社群版 Docker Image 99 [OK] docker.io docker.io/gitlab/gitlab-ee GitLab Enterprise Edition docker image bas... 89 docker.io docker.io/jangrewe/gitlab-ci-android GitLab CI image for
building Android apps 36 [OK] docker.io docker.io/centurylink/gitlab This image uses the image from sameersbn /... 24 [OK] docker.io docker.io/gitlab/dind 21 [OK] docker.io docker.io/cdrx/rancher-gitlab-deploy Painless deployment of projects built with... 19 [OK] docker.io docker.io/edbizarro/gitlab-ci-pipeline-php Build and test PHP applications with Gitla... 9 docker.io docker.io/klud/gitlab-runner GitLab Runner for ARM devices 8 docker.io docker.io/ciricihq/gitlab-sonar-scanner Gitlab Docker container to run sonar-scann... 5 [OK] docker.io docker.io/gitlab/gitlab-runner-helper 5 docker.io docker.io/gitlab/cog GitLab Bundle for Cog 3 docker.io docker.io/dockerphp/gitlab-ci-pipeline Gitlab CI pipeline for PHP applications 2 [OK] docker.io docker.io/adamkl/gitlab-merge-request-resource Customized with support for gitlab ssh on ... 1 [OK] docker.io docker.io/benyoo/gitlab 基於sameersbn/gitlab:8.9.4和GitLab 中䬮. 1 [OK] docker.io docker.io/gotfix/gitlab Dockerized Gitlab with a lot of configurab... 1 docker.io docker.io/mastertinner/gitlab-merge-request-resource A concourse resource to check for new merg... 1 [OK] docker.io docker.io/primetoninc/gitlab gitlab-ce 1 [OK] docker.io docker.io/sgillespie/gitlab-runner A Dockerized GitLab Runner that automatica... 1 [OK] docker.io docker.io/gitlab/gitlab-qa GitLab QA has a test suite that allows end... 0 docker.io docker.io/instrumentisto/gitlab-builder Docker image with minimal toolchain requir... 0 [OK] docker.io docker.io/sicony/npm-cache-gitlab-mr Concourse CI npm cache resource for gitlab... 0 docker.io docker.io/stanfordlegion/gitlab-ci An image for Gitlab CI. 0 [OK] [[email protected] ~]#
[[email protected] ~]# docker pull docker.io/gitlab/gitlab-ce
Using default tag: latest
Trying to pull repository docker.io/gitlab/gitlab-ce ... 
latest: Pulling from docker.io/gitlab/gitlab-ce
22dc81ace0ea: Pull complete 
1a8b3c87dba3: Pull complete 
91390a1c435a: Pull complete 
07844b14977e: Pull complete 
b78396653dae: Pull complete 
b7b27b5a862c: Pull complete 
b36426107b6c: Pull complete 
3368a63e7ee5: Pull complete 
9af48542e108: Pull complete 
89277d2aced7: Pull complete 
023bfed27041: Pull complete 
Digest: sha256:194d10fcb9421517ce739fb837d8b015bb9154969466e62b0ab057264f063f58
[[email protected] ~]# 

在伺服器上建立目錄

[root@master ~]# mkdir -p /docker/gitlab/config
[root@master ~]# mkdir -p /docker/gitlab/logs
[root@master ~]# mkdir -p /docker/gitlab/data
docker run  
   -d \
   -h gitlab \
   -p 2222:22 \
   -p 8888:80 \
   -p 8443:443 \
   -v /docker/gitlab/config:/etc/gitlab \
   -v /docker/gitlab/logs:/var/log/gitlab \
   -v /docker/gitlab/data:/var/opt/gitlab \
   --restart always \
   --name gitlab \
   gitlab/gitlab-ce:latest

引數說明:

--detach: 設定容器後臺執行
--hostname: 設定容器的 hostname
--publish: 埠轉發規則(80Http 訪問埠,443Https 訪問埠,8888:主機的 ssh 訪問埠,22Docker 容器中 ssh 訪問埠)
--name:容器名稱
--restart always:每次啟動容器就重啟GitLab
--volume: 共享目錄掛載,即 docker 容器內外資料共享(/srv/gitlab/data: 應用程式資料,/srv/gitlab/logs:GitLab 的 log,/srv/gitlab/config:GitLab 的配置檔案)
--e:配置 Gitlab 執行的環境變數
[[email protected] ~]# docker run  -d \
> -h gitlab \
> -p 2222:22 \
> -p 8888:80 \
> -p 8443:443 \
> -v /docker/gitlab/config:/etc/gitlab \
> -v /docker/gitlab/logs:/var/log/gitlab \
> -v /docker/gitlab/data:/var/opt/gitlab \
> --restart always \
> --name gitlab \
> gitlab/gitlab-ce:latest
735b8de9827a615cb69392f542acc33e4fecec998256af62eb9a36e8733cae12
[[email protected] ~]#

錯誤資訊:502 Whoops, GitLab is taking too much time to respond.
這裡寫圖片描述

說明gitlab還沒有準備好,再等待一會,重新整理瀏覽器,即可看到如下頁面
這裡寫圖片描述

初次使用gitlab時需要建立預設管理員密碼,至少8位,這裡輸入“12345678”。
我們在登入那裡使用root作為使用者名稱,然後用剛剛設定的密碼,就可以以管理員身份登入Gitlab。
這裡寫圖片描述

然後我們需要註冊一個普通使用者。
這裡寫圖片描述