安装docker环境和docker-compose步骤省略
docker-compose.yaml文件内容如下:
web:
image: 'gitlab/gitlab-ce:latest' //最新镜像
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com' //配置IP或域名
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab' //配置文件路径
- '/srv/gitlab/logs:/var/log/gitlab' //日志路径
- '/srv/gitlab/data:/var/opt/gitlab' //数据路径
说明:端口映射和目录映射根据需求修改
ports 中前面是宿主机端口后面是容器端口
volume中同理
比如:
ports:
- '18080:80' //18080宿主机端口80是容器端口
volumes:
- '/srv/gitlab/config:/etc/gitlab' // /srv/gitlab/config是宿主机路径 /etc/gitlab是容器内路径
配置域名使用证书(如果有的话)
1、将证书文件到/opt/gitlab/config/ssl(宿主机路径)下
2、修改配置文件 /opt/gitlab/config/gitlab.rb
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/6742283_gitlab.yzb.anystreaming.cn.pem" //证书路径
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/6742283_gitlab.yzb.anystreaming.cn.key" //证书key路径
nginx['ssl_prefer_server_ciphers'] = "on"
nginx['ssl_protocols'] = "TLSv1.2 TLSv1.3"
nginx['ssl_session_cache'] = "shared:SSL:10m"
nginx['listen_addresses'] = ['*', '[::]']
最后重启
docker-compose down //停止容器组
docker-compose up -d //启动容器组
首次登陆用户名:root
密码查看文件 /opt/gitlab/config/initial_root_password
本文不涉及邮件相关的配置