官方镜像地址  ce版本:

https://hub.docker.com/r/gitlab/gitlab-ce

文档地址:

https://docs.gitlab.com/omnibus/docker/

环境:

阿里云 centos 7.4    2核4G

首先创建好存储目录:

[root@iZbp1625jeg61bc2zzfcotZ ~]# mkdir /usr/local/gitlab_data
[root@iZbp1625jeg61bc2zzfcotZ ~]# cd /usr/local/gitlab_data/
[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# mkdir -p /usr/local/gitlab_data/gitlab/config
[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# mkdir -p /usr/local/gitlab_data/gitlab/logs
[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# mkdir -p /usr/local/gitlab_data/gitlab/data

然后下载docker下载gitlab的镜像

[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# docker pull gitlab/gitlab-ce
[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# docker images
[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# docker inspect gitlab/gitlab-ce:latest
[root@iZbp1jcx2imdc3mj7mqdh0Z gitlab_data]# docker inspect gitlab/gitlab-ce:latest | grep DockerVersion

然后开始创建容器:

[root@iZbp1625jeg61bc2zzfcotZ gitlab_data]# docker run -d \
--hostname gitlab.example.com \
--name gitlab \
--restart always \
-p : -p : -p : \
-v /etc/localtime:/etc/localtime:ro \
-v /usr/local/gitlab_data/gitlab/config:/etc/gitlab \
-v /usr/local/gitlab_data/gitlab/logs:/var/log/gitlab \
-v /usr/local/gitlab_data/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
#解释:
  #-d 指定后台运行
  #--hostname 指定主机名
  #--name 指定容器名
  #-p 端口映射
  #--restart always 指定容器停止后的重启策略: 容器退出时总是重启
  # -v 指定挂载存储卷

最后登录测试:





配置以https 方式访问的gitlab

1、无论是阿里云还是腾讯云都能获得免费的域名证书,把证书弄出来

2、修改配置文件

[root@iZbp1jcx2imdc3mj7mqdh0Z config]# pwd
/usr/local/gitlab_data/gitlab/config
[root@iZbp1jcx2imdc3mj7mqdh0Z config]# ls
gitlab.rb gitlab-secrets.json ssh_host_ecdsa_key ssh_host_ecdsa_key.pub ssh_host_ed25519_key ssh_host_ed25519_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub trusted-certs
[root@iZbp1jcx2imdc3mj7mqdh0Z config]# vim gitlab.rb

3、创建ssl目录,并将证书改名放入其中

[root@iZbp1jcx2imdc3mj7mqdh0Z config]# mkdir ssl
[root@iZbp1jcx2imdc3mj7mqdh0Z config]# cd ssl/
[root@iZbp1jcx2imdc3mj7mqdh0Z ssl]# pwd
/usr/local/gitlab_data/gitlab/config/ssl
[root@iZbp1jcx2imdc3mj7mqdh0Z ssl]# ls
gitlab.xiangdongcn.com.crt gitlab.xiangdongcn.com.key

举例:我这边是腾讯云的证书,获得:

1_gitlab.xiangdongcn.com_bundle.crt

2_gitlab.xiangdongcn.com.key

然后将其改名为:

gitlab.xiangdongcn.com.crt  
gitlab.xiangdongcn.com.key

4、安装docker-nginx

https://www.cnblogs.com/shijunjie/p/10571586.html

5、配置https访问

vim conf.d/default.conf

server {
listen ;
server_name gitlab.xiangdongcn.com;
ssl on;
ssl_certificate ssl/1_gitlab.xiangdongcn.com_bundle.crt;
ssl_certificate_key ssl/2_gitlab.xiangdongcn.com.key; location / {
proxy_pass https://172.16.77.9:8082;
proxy_set_header X_FORWARDED_PROTO https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
} error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen ;
server_name gitlab.xiangdongcn.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}

6、开启阿里云安全组的端口,测试访问





配置邮件

vim gitlab.rb

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] =
gitlab_rails['smtp_user_name'] = "xxxxxxxxxx@qq.com"
gitlab_rails['smtp_password'] = "quajsqkllubrbcdj" #开启qq的POP3时得到的密码
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'] = 'xxxxxxxxxx@qq.com'

测试配置是否成功:
执行 gitlab-rails console进入控制台。 然后在控制台提示符后输入下面的命令 发送一封测试邮件:Notify.test_email('收件人邮箱', '邮件标题', '邮件正文').deliver_now





解决gitlab上传文件大小的限制:

报错关键字:

error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

vim gitlab.rb
nginx['enable'] = true
nginx['client_max_body_size'] = '1024m'
nginx['redirect_http_to_https'] = false
nginx['redirect_http_to_https_port'] = 80
 

然后重启容器

再然后修改nginx的配置文件

vim nginx.conf

client_max_body_size 60m;  ##在http内加上


即可解决上传文件大小限制的问题。





解决nginx出现的问题:

今天有时间进入容器nginx,输入命令:

[root@iZbp1jcx2imdc3mj7mqdh0Z gitlab]# docker exec -it nginx /bin/bash
root@ae87a1c53ab2:/# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful 以上是我修复好后没问题了,但是在修复好之前,出现了两个警告! 虽然不影响nginx的启动与使用,但是还是需要排查的。

第一个警告是:

nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl"

这是因为nginx版本的问题,新版本的nginx 是不需要ssl on的,即便设置了ssl on也不影响功能,但是最好改成下图所示,在443 后面加上ssl 即可。

第二个警告是:

nginx: [warn] could not build optimal proxy_headers_hash, you should increase either proxy_headers_hash_max_size: 512 or proxy_headers_hash_bucket_size: 64; ignoring proxy_headers_hash_bucket_size 

编辑nginx.conf,在http里面增加

proxy_headers_hash_max_size ;
proxy_headers_hash_bucket_size ;





 解决gitlab出现的无法git push的问题:

有技术反馈使用HTTPS可以 clone  但是使用SSH时无法成功;

排查了很多问题,用了很多方法,终于发现了问题存在于端口上。

仔细的小伙伴能够发现我们在创建容器时,映射的端口是:

这样导致了在git push的时候无法顺利的找到容器gitlab的22端口,于是解决的办法就是:

1、先修改sshd监听的22端口,换成别的端口

2、然后docker rm -f gitlab  删除容器

3、最后重新创建容器,并修改端口映射 -p 22:22  即可

以上操作成功后,如果还是无法成功git push  有两种可能

1、公钥过期,需要技术重新制作以及上传公钥

2、git没有设置密码,docker exec -it gitlab /bin/bash 进入容器后 输入命令 passwd git 设置密码 即可。

docker 安装使用gitlab的更多相关文章

  1. docker安装配置gitlab详细过程

    docker安装配置gitlab详细过程   获取镜像 1.方法一 1 docker pull beginor/gitlab-ce:11.0.1-ce.0 2.方法二如果服务器网路不好或者pull不下 ...

  2. docker安装的gitlab的备份与恢复

    1.对docker容器安装gitlab备份 1) 查看容器id docker ps 2) 将容器备份成镜像文件 docker commit -a 'James' -m 'gitlab_backup' ...

  3. Windows10 上Docker 安装运行Gitlab

    准备条件 安装好Docker For Windows客户端. 配置好Docker 阿里云加速镜像地址. 检查Docker版本,大于等于v19. 拉取Gitlab镜像 docker pull gitla ...

  4. 使用docker安装使用gitlab

    1.下载镜像 gitlab/gitlab-ce:latest            当前gitlab最新版本为10.0.4 2.在服务器上创建目录 mkdir -p /home/work/ins/co ...

  5. docker安装中文版Gitlab服务端

    1.pull中文版镜像: docker pull beginor/gitlab-ce:11.3.0-ce.0 2.创建目录: 通常会将 GitLab 的配置 (etc) . 日志 (log) .数据 ...

  6. Docker安装Gitlab

    一.Ubuntu16.4上Docker安装Gitlab 1.安装docker 参见:https://docs.docker.com/engine/installation/linux/ubuntuli ...

  7. Ubuntu Docker 安装和配置 GitLab CI 持续集成

    相关文章: Ubuntu Docker 简单安装 GitLab 劈荆斩棘:Gitlab 部署 CI 持续集成 目的:在 Ubuntu 服务器上,使用 Docker 安装和配置 GitLab Runne ...

  8. centos7下使用docker安装gitlab

    环境背景: Docker化已经成为一种热门,记录一下使用docker引擎安装gitlab的过程. 测试环境: 系统 软件 依赖 CentOS 7.4 GitLab(latest) docker-ce ...

  9. 解决 Windows Docker 安装 Gitlab Volume 权限问题

    本文首发于我的个人博客,解决 Windows Docker 安装 Gitlab Volume 权限问题 ,欢迎访问! 记录一下 Windows10 下 Docker 安装 Gitlab 的步骤. Ca ...

随机推荐

  1. rest 参数和扩展运算符

    rest 参数和扩展运算符 rest 参数的形式为 ...变量名:扩展运算符是三个点 .... rest 参数 function add(...values) { console.log(values ...

  2. Asp.net WebPages框架运行原理浅析

    [来源] 达内    [编辑] 达内   [时间]2012-09-14 在Asp.net4和4.5中,新增了WebPages Framework,编写页面代码使用了新的Razor语法,代码更加的简洁和 ...

  3. 积分之谜——第六届蓝桥杯C语言B组(国赛)第一题

    原创 标题:积分之迷 小明开了个网上商店,卖风铃.共有3个品牌:A,B,C. 为了促销,每件商品都会返固定的积分. 小明开业第一天收到了三笔订单: 第一笔:3个A + 7个B + 1个C,共返积分:3 ...

  4. c# 读取txt文档和写入文档的方法

    StreamReader sr = new StreamReader(path); //path是要读取的文件的完整路径 String str_read = sr.ReadToEnd(); //从开始 ...

  5. 【SQL】- 基础知识梳理(五) - 触发器

    触发器的概念 触发器对表进行插入.更新.删除的时候会自动执行的特殊存储过程 触发器的语法 create trigger tgr_name on table_name with encrypion –加 ...

  6. Vue 父组件向子组件传值,传方法,传父组件整体

    父子组件传值 1.父组件调用子组件时绑定属性,例如-> :title="title" 2.子组件中在props中声明title:props:['title','msg'] 3 ...

  7. 6. 重点来啦,pytest的各种装饰圈fixtures

    pytest中,fixture的目的是什么 为可靠的和可重复执行的测试提供固定的基线.(可以理解为测试的固定配置,使不同范围的测试都能够获得统一的配置.) fixture提供了区别于传统单元测试(se ...

  8. 浅谈C#中的委托、事件与异步

    从刚接触c#编程到现在,差不多快有一年的时间了.在学习过程中,有很多地方始终似是而非,直到最近才弄明白. 本文将先介绍用法,后评断功能. 一.委托 基本用法: 1.声明一个委托类型.委托就像是‘类'一 ...

  9. [POI2007]ZAP-Queries 数学

    题目描述 Byteasar the Cryptographer works on breaking the code of BSA (Byteotian Security Agency). He ha ...

  10. 4,JavaScript数据类型

    学习要点:1.typeof 操作符2.Undefined 类型3.Null 类型4.Boolean 类型5.Number 类型6.String 类型7.Object 类型 ECMAScript 中有 ...