一、准备docker-compose.yml文件
中文版:
version: '3'
services:
gitlab:
image: 'twang2218/gitlab-ce-zh:11.1.4'
container_name: "gitlab"
restart: unless-stopped
privileged: true
hostname: 'gitlab'
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.1.8'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_shell_ssh_port'] = 22
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- /opt/gitlab/config:/etc/gitlab
- /opt/gitlab/data:/var/opt/gitlab
- /opt/gitlab/logs:/var/log/gitlab
英文版:
version: '3'
services:
gitlab:
container_name: gitlab
image: 'gitlab/gitlab-ce'
hostname: 'gitlab'
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.1.8'
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '/tmp/gitlab/conf:/etc/gitlab'
- '/tmp/gitlab/data:/var/opt/gitlab'
- '/tmp/gitlab/logs:/var/log/gitlab'
二、修改ssh端口号
因为要使用xshell工具远程连接服务器,所以需要修改ssh默认的22端口,以免冲突。
# 修改22端口为60022
vim /etc/ssh/sshd_config
修改前:
修改后:
重启sshd
systemctl restart sshd
三、安装gitlab
docker-compose up -d
gitlab的下载和安装都需要一定时间,使用docker-compose logs -f
查看日志,当出现如下信息时说明启动成功:
使用docker ps -a
查看容器信息:
访问http://ip:80可看到如下登录页面:
中文版:
英文版: