前置条件
系统: CentOS
工具: docker, docker-compose
安装
1. 拉取GitLab镜像
[root@localhost docker]# docker pull gitlab/gitlab-ce
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
32f112e3802c: Pull complete
bbf79b4b1bed: Pull complete
cee64d6186ab: Pull complete
77a652146c5b: Pull complete
79bda19958dd: Pull complete
c6917f66fb23: Pull complete
a071c753b12f: Pull complete
ce368e9fc390: Pull complete
e39ee8568473: Pull complete
Digest: sha256:182613a8f82544404884024c7f9acbd48f3c191349a52df25f2044761b0e45a1
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab/gitlab-ce latest 79a916da577b 4 days ago 3.73GB
2. 编写docker-compose.yaml
version: "3.1"
services:
gitlab:
image: gitlab/gitlab-ce:latest
container_name: gitlab
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.183.144:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:8929'
- '2224:2224'
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
3. 启动容器
[root@localhost ~]# docker-compose up -d
初始化
找出initial passord, 并初始化GitLab
#找到initial password
[root@localhost gitlab_docker]# docker exec -it gitlab bash
root@a802df94d5fa:/# cat /etc/gitlab/initial_root_password
打开GitLab,并登录

修改用户密码
user--> preference --> password

GitLab 上新建仓库
新建空白仓库,上传本地代码,本地Terminal执行
E:\z_zz\java_projects\java-web-test\java-web-test> git config --local user.name "Administrator"
E:\z_zz\java_projects\java-web-test\java-web-test> git config --local user.email "gitlab_admin_da113e@example.com"
Git提交本地项目
配置SSH Key
生成ssh key, 打开id_rsa 文件,复制内容
$ git config --global -l
user.name=xxx
user.email=xxx@qq.com #设置自己的用户名和邮箱
credential.helper=manager-core
xxx /e/z_zz/java_projects/java-web-test
$ ssh-keygen -t rsa -C 'xxx@qq.com'
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa):
/c/Users/xxx/.ssh/id_rsa already exists.
Overwrite (y/n)?
粘贴SSH Key到GitLab: user--> preference --> SSH Key
push 本地代码到仓库

403

被折叠的 条评论
为什么被折叠?



