Docker部署Gitlab
前置環(huán)境
docker 19.03.13
部署步驟
初始化配置文件
-- 拉取鏡像
docker pull beginor/gitlab-ce:10.7.5-ce.0
-- 掛載目錄 config[配置文件],logs[日志],data[數(shù)據(jù)]
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端口需要的部署方式(二選一)
第一步:啟動(dòng)docker
# 先更換端口啟動(dòng)項(xiàng)目,如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 為 外網(wǎng)訪問IP
vim /home/feature/docker/software/gitlab/config/gitlab.rb
# 配置http協(xié)議所使用的訪問地址,不加端口號(hào)默認(rèn)為80
external_url 'http://xxx.xxx.xxx.xxx:7001'
# 配置ssh協(xié)議所使用的訪問地址和端口
gitlab_rails['gitlab_ssh_host'] = 'xxx.xxx.xxx.xxx'
# 此端口是run時(shí)22端口映射的 7003 端口
gitlab_rails['gitlab_shell_ssh_port'] = 7003
第三步 修改 gitlab.yml
vim /home/feature/docker/software/gitlab/data/gitlab-rails/etc/gitlab.yml文章來源:http://www.zghlxwxcb.cn/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
遇見問題
- 執(zhí)行 docker run gitlab的時(shí)候,提示“ WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
原因:在Ubuntu上默認(rèn)是沒有開啟Swap限制的,這樣就會(huì)導(dǎo)致容器的swap限制不生效
解決方案:
第一步 將/etc/default/grub文件中的GRUB_CMDLINE_LINUX參數(shù),修改為"RUB_CMDLINE_LINUX=“cgroup_enable=memory swapaccount=1”
第二步 使用 sudo update-grub 更新系統(tǒng)的GRUB后,并重啟系統(tǒng)文章來源地址http://www.zghlxwxcb.cn/news/detail-627243.htmlGRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1
sudo update-grub
- 啟動(dòng)成功后訪問 http://xxx.xxx.xxx.xxx:7001 失敗,確認(rèn)防火墻是否開啟
到了這里,關(guān)于Docker部署Gitlab的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!