Ubuntu 通过 Docker 搭建 GitLab - /data:/var/opt/gitlab
Ubuntu 通过 Docker 搭建 GitLab
准备工作
1.)更新软件。确保你的系统是最新
sudo apt update
sudo apt upgrade -y
2.)安装 Docker 和 Docker Compose。
参考:Ubuntu 上安装 Docker-CSDN博客
1. 创建 GitLab 目录
创建一个用于存储 GitLab 数据和配置的目录:
mkdir -p ~/gitlab/config ~/gitlab/logs ~/gitlab/data
2. 创建 docker-compose.yml 文件 拼多多帮助力入口
在 ~/gitlab 目录下创建 docker-compose.yml 文件,并添加以下内容:
version: '3' services: gitlab: image: gitlab/gitlab-ee:latest # 可以根据需要选择 gitlab-ce restart: always hostname: 'gitlab.example.com' # 替换为你的域名或 IP 地址 environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://gitlab.example.com' # 替换为你的域名或 IP 地址 gitlab_rails['time_zone'] = 'Asia/Shanghai' # 设置时区 ports: - '80:80' # HTTP - '443:443' # HTTPS - '22:22' # SSH volumes: - ./config:/etc/gitlab - ./logs:/var/log/gitlab - ./data:/var/opt/gitlab
3. 启动 GitLab
在 ~/gitlab 目录中,使用 Docker Compose 启动 GitLab:
cd ~/gitlab
sudo docker-compose up -d
4. 访问 GitLab
在浏览器中访问 http://gitlab.example.com(替换为你的域名或 IP 地址),然后根据提示完成 GitLab 的初始配置。
5. 检查 GitLab 状态
要查看 GitLab 的状态,可以运行以下命令:
sudo docker-compose ps
补充:
1.)配置防火墙(可选)
sudo ufw allow http
sudo ufw allow https
sudo ufw allow ssh
Ubuntu 通过 Docker 搭建 GitLab
推荐阅读