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
相关推荐
独自归家的兔1 天前
2026年4月16日 Ubuntu系统 Docker 的安装与配置
运维·docker·容器
舒一笑1 天前
Docker 离线镜像导入后变成 <none>:<none>?一文讲透原因、排查与正确打包姿势
后端·docker·容器
Bonnienienie1 天前
服务器Docker实例化容器 -- 踩坑大全
docker
殷紫川1 天前
Docker Compose实战指南
运维·docker
鹅是开哥1 天前
XXL-Job Docker 部署中“登录无响应”的排查与解决
运维·docker·容器
HYNuyoah1 天前
3X-UI Reality 搭建指南
ubuntu·ui·docker
木雷坞1 天前
2026年4月实测:K8s containerd 镜像拉取全方案汇总
运维·容器·kubernetes
小夏子_riotous2 天前
Docker学习路径——3、常用命令
linux·运维·服务器·学习·docker·容器·centos
HYNuyoah2 天前
docker 安装win10系统
运维·docker·容器
JAVA学习通2 天前
励志从零打造LeetCode平台之C端竞赛列表
java·vscode·leetcode·docker·状态模式