使用Docker部署Gitlab服务及基础操作说明

本文介绍如何使用Docker快速部署Gitlab,并提供了一系列基础的Git客户端操作指南,包括仓库创建、克隆、文件修改及推送等关键步骤。

Docker部署Gitlab及常用基础操作

编辑docker-install-gitlab.sh脚本

#!/bin/bash

set -e

#pull gitlab image
docker pull gitlab-ce
# or offline
# docker load < `pwd`/gitlab.tar.gz

#create datadir 
mkdir -p data/gitlab
GITLAB_HOME=`pwd`/data/gitlab

#run gitlab container
docker run -d \
    --hostname gitlab \
    --publish 8443:443 --publish 8089:80 --publish 2222:22 \
    --name gitlab \
    --restart always \
    --volume $GITLAB_HOME/config:/etc/gitlab \
    --volume $GITLAB_HOME/logs:/var/log/gitlab \
    --volume $GITLAB_HOME/data:/var/opt/gitlab \
    gitlab/gitlab-ce

执行docker-install-gitlab.sh脚本即可,gitlab启动较慢(五分钟),访问localhost:8089,首次登陆需要设置root密码。

git客户端操作命令:

Git global setup
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
Create a new repository
git clone http://gitlabIP:Port/root/Andriy.git
cd Andriy
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Delete a repository
git clone http://gitlabIP:Port/root/Andriy.git
git rm -rf README.md
git commit -m "delete README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://gitlabIP:Port/root/Andriy.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlabIP:Port/root/Andriy.git
git push -u origin --all
git push -u origin --tags

在Windows上使用Docker部署GitLab,可以按照以下步骤进行操作: 1. 首先,你需要下载并安装Docker Desktop for Windows。Docker Desktop是一个Windows平台上的Docker应用容器引擎。 2. 安装完成后,打开命令提示符(cmd)窗口,运行以下命令来拉取GitLab的镜像文件: ``` docker pull gitlab/gitlab-ce ``` 这个命令将从Docker Hub上下载最新的GitLab Community Edition(gitlab-ce)的镜像文件。 3. 下载完成后,你需要创建本地映射文件夹来存储GitLab的配置、日志和数据文件。在命令提示符窗口中运行以下命令: ``` mkdir D:\DockerData\GitlabData\config mkdir D:\DockerData\GitlabData\log mkdir D:\DockerData\GitlabData\data ``` 这些命令将在D盘下创建相应的文件夹,用于存储GitLab的配置、日志和数据文件。 4. 最后,你可以运行以下命令来启动GitLab容器: ``` docker run -d ^ --hostname localhost ^ -p 80:80 ^ -p 443:443 ^ --name gitlab ^ --restart unless-stopped ^ -v D:\DockerData\GitlabData\config:/etc/gitlab ^ -v D:\DockerData\GitlabData\log:/var/log/gitlab ^ -v D:\DockerData\GitlabData\data:/var/opt/gitlab ^ gitlab/gitlab-ce:latest ``` 这个命令将在Docker中创建并运行一个GitLab容器。通过端口映射,你可以通过浏览器访问`http://localhost`来打开GitLab的界面。 在这个命令中,你需要根据实际情况修改文件夹路径和主机名等参数。 通过以上步骤,在Windows上使用Docker部署GitLab就可以顺利完成了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [windows使用docker部署gitlab](https://blog.youkuaiyun.com/qq563129582/article/details/128190394)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值