Docker部署Gitlab

Docker部署Gitlab

文章目录

前置环境

docker 19.03.13
es 7.2.0

部署步骤

初始化配置文件

shell 复制代码
-- 拉取镜像
docker pull beginor/gitlab-ce:10.7.5-ce.0

-- 挂载目录
mkdir -p /home/feature/docker/software/gitlab/config
mkdir -p /home/feature/docker/software/gitlab/logs
mkdir -p /home/feature/docker/software/gitlab/data

80端口部署方式(二选一)

shell 复制代码
 docker run --name=gitlab -d \
    -p 80:80 -p 443:443 -p 8922:22 \
    --restart always \
    -e TZ=Asia/Shanghai \
    -m 3072m
    -v /home/feature/docker/software/gitlab/config:/etc/gitlab \
    -v /home/feature/docker/software/gitlab/logs:/var/log/gitlab \
    -v /home/feature/docker/software/gitlab/data/:/var/opt/gitlab \
    beginor/gitlab-ce:10.7.5-ce.0

非80端口需要的部署方式(二选一)

shell 复制代码
# 先更换端口启动项目,如7001 置换为原来的80
 docker run --name=gitlab -d \
    -p 7001:7001 -p 7002:443 -p 7003:22 \
    --restart always \
    -e TZ=Asia/Shanghai \
    -m 3072m
    -v /home/feature/docker/software/gitlab/config:/etc/gitlab \
    -v /home/feature/docker/software/gitlab/logs:/var/log/gitlab \
    -v /home/feature/docker/software/gitlab/data/:/var/opt/gitlab \
    beginor/gitlab-ce:10.7.5-ce.0

xxx.xxx.xxx.xxx 为 外网访问IP

修改 gitlab.rb

vim /home/feature/docker/software/gitlab/config/gitlab.rb

shell 复制代码
# 配置http协议所使用的访问地址,不加端口号默认为80
external_url 'http://xxx.xxx.xxx.xxx:7001'
# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = 'xxx.xxx.xxx.xxx'
# 此端口是run时22端口映射的99端口
gitlab_rails['gitlab_shell_ssh_port'] = 7003

修改 gitlab.yml

vim /home/feature/docker/software/gitlab/data/gitlab-rails/etc/gitlab.yml

shell 复制代码
gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: xxx.xxx.xxx.xxx 
    port: 7001
    https: false

    # Uncommment this line below if your ssh host is different from HTTP/HTTPS one
    # (you'd obviously need to replace ssh.host_example.com with your own host).
    # Otherwise, ssh host will be set to the `host:` value above
    ssh_host: xxx.xxx.xxx.xxx

刷新配置

shell 复制代码
docker exec -it gitlab gitlab-ctl restart
相关推荐
later_rql40 分钟前
k8s-集群部署1
云原生·容器·kubernetes
漫无目的行走的月亮4 小时前
在Docker中运行微服务注册中心Eureka
docker
大G哥6 小时前
记一次K8S 环境应用nginx stable-alpine 解析内部域名失败排查思路
运维·nginx·云原生·容器·kubernetes
大道归简7 小时前
Docker 命令从入门到入门:从 Windows 到容器的完美类比
windows·docker·容器
zeruns8027 小时前
如何搭建自己的域名邮箱服务器?Poste.io邮箱服务器搭建教程,Linux+Docker搭建邮件服务器的教程
linux·运维·服务器·docker·网站
爱跑步的程序员~7 小时前
Docker
docker·容器
福大大架构师每日一题8 小时前
23.1 k8s监控中标签relabel的应用和原理
java·容器·kubernetes
程序那点事儿8 小时前
k8s 之动态创建pv失败(踩坑)
云原生·容器·kubernetes
疯狂的大狗8 小时前
docker进入正在运行的容器,exit后的比较
运维·docker·容器
长天一色8 小时前
【Docker从入门到进阶】01.介绍 & 02.基础使用
运维·docker·容器