gitlab docker image
https://hub.docker.com/r/gitlab/gitlab-ce/
https://docs.gitlab.com/omnibus/docker/
https://gitlab.com/gitlab-org/gitlab-ce/tree/master/docker
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
搜索gitlab镜像
[root@centos ~]# docker search gitlab
下载gitlab镜像
[root@centos ~]# docker pull gitlab/gitlab-ce
运行gitlab容器
[root@centos ~]# docker run -d -h gitlab –name gitlab –restart always -p 443:443 -p 80:80 -p 22:22 -v /srv/gitlab/config:/etc/gitlab -v /srv/gitlab/logs:/var/log/gitlab -v /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest
-d
-h gitlab 指定容器的主机名。
–name gitlab 指定容器的名称。
–restart always
-p 443:443
-p 80:80
-p 22:22 端口映射。
-v /srv/gitlab/config:/etc/gitlab
-v /srv/gitlab/logs:/var/log/gitlab
-v /srv/gitlab/data:/var/opt/gitlab 目录挂载。
本地的端口 容器中的端口 描述
443 443 HTTPS
80 80 HTTP
22 22 SSH
本地的位置 容器中的位置 描述
/srv/gitlab/config /etc/gitlab 存储应用数据
/srv/gitlab/logs /var/log/gitlab 存储日志
/srv/gitlab/data /var/opt/gitlab 存储GitLab配置文件
查看gitlab容器
[root@centos ~]# docker ps
GitLab配置文件
/etc/gitlab/gitlab.rb
[root@centos ~]# docker exec -it gitlab /bin/bash
root@gitlab:/# vim /etc/gitlab/gitlab.rb
root@gitlab:/# gitlab-ctl reconfigure
[root@centos ~]# docker exec -it gitlab vi /etc/gitlab/gitlab.rb
[root@centos ~]# docker exec -it gitlab vim /etc/gitlab/gitlab.rb
[root@centos ~]# docker restart gitlab
GitLab配置文件/etc/gitlab/gitlab.rb
EXTERNAL_URL设置
external_url ‘http://10.10.2.123’
SMTP配置(以[email protected]为例)
gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.bnet.cn”
gitlab_rails[‘smtp_port’] = 25
gitlab_rails[‘smtp_user_name’] = “[email protected]”
gitlab_rails[‘smtp_password’] = “123456”
gitlab_rails[‘smtp_domain’] = “163.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = false
gitlab_rails[‘smtp_tls’] = false
EMAIL设置(以[email protected]为例)
gitlab_rails[‘gitlab_email_enabled’] = true
gitlab_rails[‘gitlab_email_from’] = ‘[email protected]’
gitlab_rails[‘gitlab_email_display_name’] = ‘user_support’
gitlab_rails[‘gitlab_email_reply_to’] = ‘[email protected]’
gitlab_rails[‘gitlab_email_subject_suffix’] = ”
如果端口映射
ssh 4422:22
gitlab_rails[‘gitlab_shell_ssh_port’] = 4422
配置完成后,需要重启gitlab,或重启docker
在容器里执行gitlab-ctl reconfigure,如:Docker exec –d gitlab-ctl reconfigure
或者 执行: docker restart gitlab
测试邮件是否正常发送
[root@centos ~]# docker exec -it gitlab /bin/bash
root@gitlab:/# gitlab-rails console
Loading production environment (Rails 4.2.8)
irb(main):001:0> Notify.test_email(‘[email protected],’subject’,’body’).deliver_now