docker(docker-compose)安装部署gitlab并使用iredmail发送邮件

使用docker来部署确实是比较简单的事情,只是在使用自建的iredmail发送邮件的时候,找不到连接方法。折腾了有一天时间,终于找到了合适的SMTP参数,以此作为笔记,给自己也给需要的人留下记录。
重点在于
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = false
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘none’

一、centos7上安装docker和docker-compose

1、使用 root 权限登录 Centos。

确保 yum 包更新到最新。

使用YUM直接安装docker

$ sudo yum update
$ sudo yum install docker-ce

2、禁用selinux

/etc/selinux/config 由修改为disabled

setenforce 0

3、防火墙禁用或者开放端口

systemctl stop firewalld
firewall-cmd --add-port=80/tcp --permanent

firewall-cmd --add-port=443/tcp --permanent

firewall-cmd --add-port=1022/tcp --permanent

systemctl reload firewalld

4、建议更换国内源

vim /etc/docker/daemon.json

{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}

5、安装docker-compose

#下载
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

#给予执行权限
sudo chmod +x /usr/local/bin/docker-compose

二、创建docker容器

1、进入/usr/local 建立gitlab和三个文件夹

mkdir -p gitlab/{data,config,logs}

2、创建docker-compose.yml配置文件

vim /usr/local/gitlab/docker-compose.yml

version: '3'
services:
    gitlab:
      image: 'twang2218/gitlab-ce-zh:11.1.4'
      restart: unless-stopped
      hostname: 'gitlab.example.com'
      container_name: gitlab
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://gitlab.example.com/'
          gitlab_rails['gitlab_shell_ssh_port'] = 1022
          gitlab_rails['time_zone'] = 'Asia/Shanghai'
          gitlab_rails['smtp_enable'] = true
          gitlab_rails['smtp_address'] = "smtp.example.com"
          gitlab_rails['smtp_port'] = 587
          gitlab_rails['smtp_user_name'] = "[email protected]"
          gitlab_rails['smtp_password'] = "password"
          gitlab_rails['smtp_domain'] = "example.com"
          gitlab_rails['smtp_authentication'] = "login"
          gitlab_rails['smtp_enable_starttls_auto'] = true
          gitlab_rails['smtp_tls'] = false
          gitlab_rails['smtp_openssl_verify_mode'] = 'none'
          gitlab_rails['gitlab_email_from'] = '[email protected]'
          gitlab_rails['gitlab_email_enabled'] = true
      ports:
        - '80:80'
        - '443:443'
        - '1022:22'
      volumes:
        - ./data:/var/opt/gitlab
        - ./config:/etc/gitlab
        - ./logs:/var/log/gitlab

3、运行docker-compose

docker-compose up -d

关闭docker-compose

docker-compose down

其他docker基本命令不一一列举了

docker exec -it gitlab /bin/bash
docker stop gitlab
docker ps -a

三、开始使用gitlab

http://IP 或者 http://gitlab.example.com/

你可能感兴趣的:(docker(docker-compose)安装部署gitlab并使用iredmail发送邮件)