GitLab容器部署
官方文档
1、Docker部署GitLab
设置存储位置变量
export GITLAB_HOME=/root/container/gitlab
启动容器
sudo docker run --detach \
--hostname 172.21.0.13 \
--publish 443:443 --publish 80:8080 --publish 22:22 \
--name gitlab \
--restart always \
--volume $GITLAB_HOME/config:/etc/gitlab:Z \
--volume $GITLAB_HOME/logs:/var/log/gitlab:Z \
--volume $GITLAB_HOME/data:/var/opt/gitlab:Z \
--shm-size 256m \
registry.gitlab.cn/omnibus/gitlab-jh:latest
gitlab初始化需要稍微等待一会~ 可以使用 `sudo docker logs -f gitlab跟踪整个过程
sudo docker logs -f gitlab
获取密码 此密码24小时内失效
sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
更改密码
点击 左上角 三 > 管理员 > 用户 > 编辑 > 修改密码
2、compose部署GitLab
设置存储位置变量
export GITLAB_HOME=/root/container/gitlab
创建 docker-compose文件
version: '3.6'
services:
web:
image: 'registry.gitlab.cn/omnibus/gitlab-jh:latest'
restart: always
hostname: '172.21.0.13'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://172.21.0.13'
ports:
- '80:8080'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'
运行
docker-compose up -d
获取密码 此密码24小时内失效
sudo docker exec -it gitlab-web-1 grep 'Password:' /etc/gitlab/initial_root_password
更改密码
点击 左上角 三 > 管理员 > 用户 > 编辑 > 修改密码
3、容器部署修改端口操作
vim gitlab.rb
# 访问gitlab连接地址
external_url 'https://172.21.0.13'
# SSH服务地址,即本机IP地址
gitlab_rails['gitlab_ssh_host'] = '172.21.0.13'
# SSH端口,需要写docker映射的端口
gitlab_rails['gitlab_shell_ssh_port'] =22
# 设置时区为东八区,即北京时间
gitlab_rails['time_zone'] = 'Asia/Shanghai'
进入容器执行
docker exec -it gitlab-web-1 /bin/bash
vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
修改为对应的IP+端口

在容器里面执行 重启操作
gitlab-ctl reconfigure
gitlab-ctl start

浙公网安备 33010602011771号