代码仓库管理——搭建企业私有代码仓库GitLab
代码仓库管理——搭建企业私有代码仓库GitLab
设置卷位置
在设置其他所有内容之前,配置一个新的环境变量,$GITLAB_HOME 指向配置、日志和数据文件所在的目录。确保该目录存在并且已授予适当的权限。
将路径设置为/srv/gitlab:
export GITLAB_HOME=/srv/gitlab
|
Local location |
Container location |
Usage |
|---|---|---|
|
|
|
For storing application data. |
|
|
|
For storing logs. |
|
|
|
For storing the GitLab configuration files. |
1,使用 Docker Engine 安装 GitLab
sudo docker run --detach \
--hostname gitlab.example.com \ #是服务器地址 也可以填写你的域名 如
--publish 443:443 --publish 80:80 --publish 22:22 \ #publish参数将容器的端口映射到主机,保证网络内的其他机器可以访问GitLab,80是http协议所用端口,443是https协议所用端口,22是ssh协议所用端口。
--name gitlab \
--restart always \ #restart参数指定容器由于某种原因退出时是否重启
--volume $GITLAB_HOME/config:/etc/gitlab \ #volume参数将容器内的路径映射到主机文件系统,使GitLab的持久化数据能保存在主机上
--volume $GITLAB_HOME/logs:/var/log/gitlab \
--volume $GITLAB_HOME/data:/var/opt/gitlab \ #容器内的/var/opt/gitlab存储GitLab应用数据,/var/log/gitlab存储日志,/etc/gitlab存储GitLab相关的配置文件。
--shm-size 256m \
gitlab/gitlab-ce:latest
2,使用docker-compose 安装GitLab
-
创建一个
docker-compose.yml文件:version: '3.6' services: web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'https://gitlab.example.com' # Add any other gitlab.rb configuration here, each on its own line ports: - '80:80' - '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.yml并启动 GitLab:docker compose up -d

浙公网安备 33010602011771号