docker安装中文版gitlab(转载)

2021年11月21日 阅读数:9
这篇文章主要向大家介绍docker安装中文版gitlab(转载),主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

1.pull中文版镜像:

docker pull beginor/gitlab-ce:11.3.0-ce.0

2.建立目录:

    一般会将 GitLab 的配置 (etc) 、 日志 (log) 、数据 (data) 放到容器以外, 便于往后升级, 所以请先准备这三个目录。git

mkdir -p /usr/local/gitlab/etc
mkdir -p /usr/local/gitlab/log
mkdir -p /usr/local/gitlab/data

3.修改目录权限: 

chmod 777 /usr/local/gitlab/etc
chmod 777 /usr/local/gitlab/log
chmod 777 /usr/local/gitlab/dataweb

4.运行:

    准备好这三个目录以后, 就能够开始运行 Docker 镜像了:docker

docker run --detach --publish 8443:443 --publish 8888:80 --publish 8222:22 --name gitlab --restart unless-stopped --volume /usr/local/gitlab/etc:/etc/gitlab --volume /usr/local/gitlab/log:/var/log/gitlab --volume /usr/local/gitlab/data:/var/opt/gitlab --privileged=true beginor/gitlab-ce:11.3.0-ce.0

    --publish 8443:443:将http:443映射到外部端口8443
    --publish 8888:80:将web:80映射到外部端口8888
    --publish 8222:22:将ssh:22映射到外部端口8222
    --name gitlab 运行容器名
    --restart unless-stopped 重启策略
    --volume /usr/local/gitlab/etc:/etc/gitlab 挂载目录
    --volume /usr/local/gitlab/log:/var/log/gitlab 挂载目录
    --volume /usr/local/gitlab/data:/var/opt/gitlab 挂载目录
    --privileged=true 使得容器内的root拥有真正的root权限。不然,container内的root只是外部的一个普通用户权限vim

5.访问:

    稍等片刻,初始化完毕,再打开浏览器:ip地址:8888 (http://192.168.2.212:8888/)浏览器

    修改密码为:123456789,修改完成:使用 用户名root,密码为123456789进行登录。bash

 

邮件发送配置:

cd /usr/local/gitlab/etc    跳转至挂载目录服务器

vim gitlab.rbless

    开启qq邮箱的POP3/SMTP服务并保存好受权码:dom

    在gitlab.rb末尾加上:ssh

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "1066394274@qq.com"
gitlab_rails['smtp_password'] = "受权码"
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '1066394274@qq.com'

    进入容器内部:

docker exec -it gitlab bash

    重启生效:

gitlab-ctl reconfigure

    测试配置是否成功:

gitlab-rails console    进入控制台

Notify.test_email('1107592245', '邮件标题', '邮件正文').deliver_now     向测试邮箱发送测试邮件

    发送测试邮件:

    发现有一封新的邮件:

    点击连接:

   此处将

    http://d7136f987efd/users/confirmation?confirmation_token=KWEVNipWBy2DjkFji4-X

    d7136f987efd 置换为 192.168.2.212:8080

    访问以后,激活成功。

    生成SSH私钥:

[root@localhost ~]# ssh-keygen -o -t rsa -C "1066394274@qq.com" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:DYH3I8KhprEb/N6E0ErkR+Chjes4rwo1orSqhrtOCBE 1066394274@qq.com
The key's randomart image is:
+---[RSA 4096]----+
|E o    ..        |
| * o  o ..       |
|+ + .o o..       |
| =.oo o .oo      |
|+o*=o  .S...     |
|B+*= .           |
|B+.+. .          |
|=+. .o           |
|%=... .          |
+----[SHA256]-----+
[root@localhost ~]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDSMr3ihBbSbjXQaJTjxBNiMpExUMz0J4LZ/2xCxYpUWvQs/9pmbhCl7Do9Y8TbebBy3yxUVINB8yIqgKwsX3XnXsE3TEHXKI+/dbrjlxhK49dghT6kyJwsCE1fQ4JbUz8cX7WsYysuOR326Wajdud+e14KGuuozV3ooAfmhBnTqEvj7PULCOMsLD1bftMmNvbeVRW4KSE7wWrdGurD3v5gAPMhfDDAs72g8qApsW0nyunnMd+OyQRtsD7V+y5Tlk3f1pnEE2yTXxYg5REHQhMyrfoH+MHGAHQH226sFQ106Y8IiJPIAs4zL9CTkiz4dPsOmpzyTt5f7RjJhyLUI0rM5StkZsu/bbchgMppQK4/CZtg/rBIygRB0zmisgdDZA2kpfvPmM7MCBFrYdIuutz/HjIkyg8+RnvTDEo0CBgbs1X0Nm3zL7P6MB6RlW4Zsz5fSrn49FH3pylyR2wkkebd86L53p+3117SrBH2FQEYsgwYGpcOBv8ZC3w25+7/ExrCoyx6VRbf4bqsyZ7gsX8sAHsRlEeCpiI1kGZXvYJj5jFoaq3zsDTEwn6miQINJYJVIhOnPUsDHxK7IHLu2Grd/W6EtZaLJ1je4xXpgdMDMe7/HM8rZ0RPXP90xkg/7hXmGLxd+exlp1t9GkjZ5ogQ2ZSyBSMt5oN5oGzUEBjLeQ== 1066394274@qq.com

 

 

    项目path错误:

docker exec -it gitlab vim /etc/gitlab/gitlab.rb

 

    修改成当前服务器ip;中止删除容器:

docker stop gitlab

docker rm gitlab

    重启系统:

reboot

    运行容器:

docker run --detach --publish 8443:443 --publish 8888:8888 --publish 8222:22 --name gitlab --restart unless-stopped --volume /usr/local/gitlab/etc:/etc/gitlab --volume /usr/local/gitlab/log:/var/log/gitlab --volume /usr/local/gitlab/data:/var/opt/gitlab --privileged=true beginor/gitlab-ce:11.3.0-ce.0

    将内部端口号从80改成和外部端口一致的8888

    此时,使用http和ssh拉取,均能成功:

    

 

升级

    小版本升级(例如从 8.8.2 升级到 8.8.3), 参照官方的说明, 将原来的容器中止, 而后删除:

docker stop gitlab
docker rm gitlab

    而后从新拉一个新版本的镜像下来:

docker pull beginor/gitlab-ce:11.3.0-ce.0

    还使用原来的运行命令运行:

docker run 
    --detach 
    --publish 8443:443 
    --publish 8080:80 
    --name gitlab 
    --restart unless-stopped 
    --volume /mnt/sda1/gitlab/etc:/etc/gitlab 
    --volume /mnt/sda1/gitlab/log:/var/log/gitlab 
    --volume /mnt/sda1/gitlab/data:/var/opt/gitlab 
    beginor/gitlab-ce:11.3.0-ce.0

    大版本升级(例如从 8.7.x 升级到 8.8.x)用上面的操做有可能会出现错误, 若是出现错误能够尝试登陆到容器内部, 能够用 docker exec , 也能够用 ssh , 依次执行下面的命令:

gitlab-ctl reconfigure
gitlab-ctl restart

 

错误处理:

docker 容器提示没安装vim:

apt-get update

apt-get install vim

 中止全部的container:

docker stop $(docker ps -a -q)

    删除全部container:

docker rm $(docker ps -a -q)