3f755a615ee2f6f33220f8f209e81181.png
  • 安裝 python 環境
    為了方便地使用並執行 docker,docker-compose 會簡化不少事情!!
    yum install -y epel-release python-pip
  • 安裝 docker-compose
    sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
    sudo chmod +x /usr/bin/docker-compose
    
  • 透過 docker-compose 啟動 gitlab 
    mkdir -p /home/git/data
    cd /home/git
    
    wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml
    
    docker-compose up
    是不是輕鬆又愉快啊!!
  • 手動安裝
    如果你要純手工打造也可以,就是要一個一個安裝相關的 container (postgresql, redis, gitlab)
    # postgresql
    docker run --name gitlab-postgresql -d \
        --env 'DB_NAME=gitlabhq_production' \
        --env 'DB_USER=gitlab' --env 'DB_PASS=password' \
        --env 'DB_EXTENSION=pg_trgm' \
        --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \
        sameersbn/postgresql:latest
     
    # radis
    docker run --name gitlab-redis -d \
        --volume /srv/docker/gitlab/redis:/var/lib/redis \
        sameersbn/redis:latest
     
    #gitlab
    docker run --name gitlab -d \
        --link gitlab-postgresql:postgresql --link gitlab-redis:redisio \
        --publish 10022:22 --publish 10080:80 \
        --env 'GITLAB_PORT=10080' --env 'GITLAB_SSH_PORT=10022' \
        --env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
        --env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
        --env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
        --volume /srv/docker/gitlab/gitdata:/home/git/data \
        sameersbn/gitlab:10.8.4
    
    啟動
    docker start gitlab-postgresql
    docker start gitlab-redis
    docker start gitlab
  • 連線設定
    裝好之後,應該就可以輸入 http://your-host-ip:10080 看看有沒有成功囉! 
  • 備份 (要相同版本)
    docker run \
    --name='gitlab_backup' \
    -it \
    --rm \
    --link gitlab-postgresql:postgresql --link gitlab-redis:redisio \
    --env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
    --env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
    --env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
    -v /var/run/docker.sock:/run/docker.sock \
    -v $(which docker):/bin/docker \
    -v /srv/docker/gitlab/gitdata:/home/git/data \
    -v /srv/docker/gitlab/log/log:/var/log/gitlab \
    sameersbn/gitlab:10.8.4 app:rake gitlab:backup:create
    
    
     
    如果是透過 docker-compose 的話,比較簡單
    docker-compose rm -sf gitlab
    docker-compose run --rm gitlab app:rake gitlab:backup:create
  • 還原
    docker run \
    --name='gitlab_restore' \
    -it \
    --rm \
    --link gitlab-postgresql:postgresql \
    --link gitlab-redis:redisio \
    --env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
    --env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
    --env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
    -v /var/run/docker.sock:/run/docker.sock \
    -v $(which docker):/bin/docker \
    -v /srv/docker/gitlab/gitdata:/home/git/data \
    -v /srv/docker/gitlab/log:/var/log/gitlab \
    sameersbn/gitlab:10.8.4 app:rake gitlab:backup:restore
    
回應
訪客如要回應,請先 登入