gitlab|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

启动成功
gitlab|docker安装gitlab
文章图片

修改密码
注意:在重置密码前可以试试默认用户名和密码(默认的用户名: admin@example.com
密码: 8fGUrEIN
注册账号
gitlab|docker安装gitlab
文章图片

完成
gitlab|docker安装gitlab
文章图片

创建组( group)
gitlab|docker安装gitlab
文章图片

创建用户(people)
gitlab|docker安装gitlab
文章图片

gitlab|docker安装gitlab
文章图片

创建项目(project)
gitlab|docker安装gitlab
文章图片

gitlab|docker安装gitlab
文章图片

配置
# 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

gitlab|docker安装gitlab
文章图片

Docker Jenkins Pipeline配置ssh key从gitlab拉取代码
进入jenkins容器生成ssh key
[root@wenhui config]# docker ps CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES 7786c2507b09gitlab/gitlab-ce:latest"/assets/wrapper"3 hours agoUp 15 minutes (healthy)0.0.0.0:8222->22/tcp, 0.0.0.0:8880->80/tcp, 0.0.0.0:8443->443/tcpgitlab d512f2523fd5jenkins:2.60.3"/bin/tini -- /usr..."26 hours agoUp 2 hours0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcpjenkins [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 bindevetclibmediaoptroot sbinsysusr bootdocker-java-home homelib64mntprocrun srvtmpvar 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

【gitlab|docker安装gitlab】gitlab|docker安装gitlab
文章图片

GitLab配置ssh key完成
gitlab|docker安装gitlab
文章图片

idea中Gitlab项目导入导出
gitlab|docker安装gitlab
文章图片

gitlab|docker安装gitlab
文章图片

gitlab|docker安装gitlab
文章图片

创建项目提交代码
gitlab|docker安装gitlab
文章图片

gitlab查看代码更新
gitlab|docker安装gitlab
文章图片

    推荐阅读