- 拉取镜像:docker pull gitlab/gitlab-ce
- 创建映射目录:
mkdir -p /usr/local/gitlab/config
mkdir -p /usr/local/gitlab/data
mkdir -p /usr/local/gitlab/logs - 运行容器:
bash
docker run -d -p 443:443 -p 8000:8000 -p 222:22 --name gitlab --restart always -v /usr/local/gitlab/config:/etc/gitlab -v /usr/local/gitlab/logs:/var/log/gitlab -v /usr/local/gitlab/data:/var/opt/gitlab gitlab/gitlab-c
- 修改gitlab.rb:vim /usr/local/gitlab/config/gitlab.rb
把external_url改成部署机器的域名或ip地址,不加端口默认80
bash
external_url 'http://192.168.202.130'
gitlab_rails['gitlab_shell_ssh_port'] = 222
如果被映射的端口不是80,需要修改
bash
nginx['listen_port'] = 8000
external_url 'http://192.168.202.130:8000'
gitlab_rails['gitlab_shell_ssh_port'] = 222
- 修改gitlab.yml vim /usr/local/gitlab/data/gitlab-rails/etc/gitlab.yml
bash
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 192.168.202.130
port: 8000
- 如果8080端口被Tomcat占用,会出现502的页面
vim /usr/local/gitlab/config/gitlab.rb
bash
# 假设有Tomcat占用了8080,因此改为8082试一试
unicorn['listen'] = '127.0.0.1'
- 配置并启动GitLab
进入容器:docker exec -ti gitlab /bin/bash
刷新配置
bash
gitlab-ctl reconfigure #花时间比较多
gitlab-ctl restart #改IP重启就可以了
- 退出并重启容器
bash
docker restart gitlab
- 访问登录
bash
192.168.202.130:8000
默认 user:root;password:root 登录是会重定向到修改密码界面