Docker部署Gitlab
前置环境
docker 19.03.13
部署步骤
初始化配置文件
-- 拉取镜像
docker pull beginor/gitlab-ce:10.7.5-ce.0
-- 挂载目录 config[配置文件],logs[日志],data[数据]
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端口部署方式(二选一)
docker run --name=gitlab -d \
-p 80:80 -p 443:443 -p 22: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端口需要的部署方式(二选一)
第一步:启动docker
# 先更换端口启动项目,如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
第二步 修改 gitlab.rb文件
xxx.xxx.xxx.xxx 为 外网访问IP
vim /home/feature/docker/software/gitlab/config/gitlab.rb
# 配置http协议所使用的访问地址,不加端口号默认为80
external_url 'http://xxx.xxx.xxx.xxx:7001'
# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = 'xxx.xxx.xxx.xxx'
# 此端口是run时22端口映射的 7003 端口
gitlab_rails['gitlab_shell_ssh_port'] = 7003
第三步 修改 gitlab.yml
vim /home/feature/docker/software/gitlab/data/gitlab-rails/etc/gitlab.yml文章来源:https://www.toymoban.com/news/detail-627243.html
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
刷新配置
docker exec -it gitlab gitlab-ctl restart
遇见问题
- 执行 docker run gitlab的时候,提示“ WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
原因:在Ubuntu上默认是没有开启Swap限制的,这样就会导致容器的swap限制不生效
解决方案:
第一步 将/etc/default/grub文件中的GRUB_CMDLINE_LINUX参数,修改为"RUB_CMDLINE_LINUX=“cgroup_enable=memory swapaccount=1”
第二步 使用 sudo update-grub 更新系统的GRUB后,并重启系统文章来源地址https://www.toymoban.com/news/detail-627243.htmlGRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1
sudo update-grub
- 启动成功后访问 http://xxx.xxx.xxx.xxx:7001 失败,确认防火墙是否开启
到了这里,关于Docker部署Gitlab的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!