docker安装gitlab

下载镜像

docker pull gitlab/gitlab-ce

创建目录

mkdir -p /usr/local/gitlab/config
mkdir -p /usr/local/gitlab/logs 
mkdir -p /usr/local/gitlab/data

启动运行

docker run -detach \
  --publish 8443:443 --publish 8880:80 --publish 8222:22 \
  --name gitlab \
  --restart always \
  --volume /usr/local/gitlab/config:/etc/gitlab \
  --volume /usr/local/gitlab/logs:/var/log/gitlab \
  --volume /usr/local/gitlab/data:/var/opt/gitlab \
  --privileged=true \
  gitlab/gitlab-ce:latest

启动成功
docker安装gitlab_第1张图片

修改密码

注意:在重置密码前可以试试默认用户名和密码(默认的用户名: [email protected]
密码: 8fGUrEIN

注册账号

docker安装gitlab_第2张图片
完成
docker安装gitlab_第3张图片

创建组( group)

docker安装gitlab_第4张图片

创建用户(people)

docker安装gitlab_第5张图片
docker安装gitlab_第6张图片

创建项目(project)

docker安装gitlab_第7张图片
docker安装gitlab_第8张图片

配置

# gitlab.rb文件内容默认全是注释
vi /usr/local/gitlab/config/gitlab.rb 
# 配置http协议所使用的访问地址,不加端口号默认为80
external_url 'http://192.168.2.145/'

# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = '192.168.2.145'
gitlab_rails['gitlab_shell_ssh_port'] = 8222 # 此端口是run时22端口映射的222端口
:wq #保存配置文件并退出
# 重启gitlab容器
docker restart gitlab

docker安装gitlab_第9张图片

Docker Jenkins Pipeline配置ssh key从gitlab拉取代码

进入jenkins容器生成ssh key

[root@wenhui config]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                    PORTS                                                               NAMES
7786c2507b09        gitlab/gitlab-ce:latest   "/assets/wrapper"        3 hours ago         Up 15 minutes (healthy)   0.0.0.0:8222->22/tcp, 0.0.0.0:8880->80/tcp, 0.0.0.0:8443->443/tcp   gitlab
d512f2523fd5        jenkins:2.60.3            "/bin/tini -- /usr..."   26 hours ago        Up 2 hours                0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp                    jenkins
[root@wenhui config]# docker exec -it d512f2523fd5 /bin/bash
jenkins@d512f2523fd5:/$ cd ~/.ssh
bash: cd: /var/jenkins_home/.ssh: No such file or directory
jenkins@d512f2523fd5:/$ mkdir ~/.ssh
jenkins@d512f2523fd5:/$ ls
bin   dev		etc   lib    media  opt   root	sbin  sys  usr
boot  docker-java-home	home  lib64  mnt    proc  run	srv   tmp  var
jenkins@d512f2523fd5:/$ cd ~/.ssh
jenkins@d512f2523fd5:~/.ssh$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/var/jenkins_home/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /var/jenkins_home/.ssh/id_rsa.
Your public key has been saved in /var/jenkins_home/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:0Kt8PsWZkfTtsBSM8HX5CLupcCEjwp+BFzyKYyfCeRA jenkins@d512f2523fd5
The key's randomart image is:
+---[RSA 2048]----+
| E.  .  .. o. .. |
| .    +. .o.+..  |
|. oo o.o...o = o |
|.o=.* +.o.+ = o .|
| o.+ + +S+ * *   |
|     .o.. * + .  |
|      o .+ .     |
|       o. .      |
|        ..       |
+----[SHA256]-----+
jenkins@d512f2523fd5:~/.ssh$ 
jenkins@d512f2523fd5:~/.ssh$ ls
id_rsa	id_rsa.pub
jenkins@d512f2523fd5:~/.ssh$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0TunE/sXgQQHMjbfekkqe2sng9PBmsMd0uQzz/q91rM7F7zXa70G1jpkW4SKyyNLJ7otJDozWAJ7UylwRpUHk/r+E8ym4zfZd796qOApcDgMJQW3M8ZUIt/e76LDB4ZGPR0Zp23a8nOuEE77gsKryb6VzqpSnbTe4MHJANUjhSqjdno4B6FvSQrcVEMryOFzDAEsIIeNuG8ChpU6qYKC+Em5+0QNEO0cPQ3ZdmK3ZlRq/0CKd6Co8Ki8Ug87MCBypwjQoYq99mX5THYywzb2QiUBlPPZrj8Hk0asujCqeS9zEubf5it69YnJqAK1 jenkins@d512f2523fd5

docker安装gitlab_第10张图片
GitLab配置ssh key完成
docker安装gitlab_第11张图片

idea中Gitlab项目导入导出

docker安装gitlab_第12张图片
docker安装gitlab_第13张图片
docker安装gitlab_第14张图片
创建项目提交代码
docker安装gitlab_第15张图片
gitlab查看代码更新
docker安装gitlab_第16张图片

你可能感兴趣的:(gitlab,gitlab)