Docker安装Gitlab服务器并配置使用(完整版)
作者:互联网
一、安装及配置
1.1 Gitlab镜像拉取
docker pull gitlab/gitlab-ce 拉取最新稳定版本
[root@nb001 ~]# docker pull gitlab/gitlab-ce
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
7b1a6ab2e44d: Pull complete
f6840fc7ad2b: Pull complete
c51f7b37a5cc: Pull complete
29a0a36b643a: Pull complete
c1987bebb5f7: Pull complete
d5f43e65df39: Pull complete
df2f669ba256: Pull complete
3476712af3f1: Pull complete
Digest: sha256:3b24d9cf000a362d5cef276a4718ed8dcd05137c96961ac115069e4fd79fb307
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest
1.2 运行Gitlab镜像
docker run --name gitlab --restart always -p 4433:443 -p 8888:80 -p 222:22 -v /data/gitlab/config:/etc/gitlab -v /data/gitlab/logs:/var/log/gitlab -v /data/gitlab/data:/var/opt/gitlab -d gitlab/gitlab-ce
【建议看完全文,再开始操作哈】
[root@nb001 data]# docker run --name gitlab --restart always -p 4433:443 -p 8888:80 -p 222:22 -v /data/gitlab/config:/etc/gitlab -v /data/gitlab/logs:/var/log/gitlab -v /data/gitlab/data:/var/opt/gitlab -d gitlab/gitlab-ce
a9b9ef1c6a619ac7e0869b29a461c04fde26bd58383345c115c94e93a482f71b
docker ps 查看运行情况:
[root@nb001 data]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a9b9ef1c6a61 gitlab/gitlab-ce "/assets/wrapper" 19 seconds ago Up 18 seconds (health: starting) 0.0.0.0:222->22/tcp, :::222->22/tcp, 0.0.0.0:8888->80/tcp, :::8888->80/tcp, 0.0.0.0:4433->443/tcp, :::4433->443/tcp gitlab
二、配置
2.1 配置gitlab
编辑gitlab.rb文件,修改以下几个配置的值:
vim /data/gitlab/config/gitlab.rb
# 配置http协议所使用的访问地址,端口为上述docker run中配置的端口8888
external_url 'http://192.168.1.127:8888'
# 配置ssh协议所使用的访问地址和端口(端口为上述docker run中配置的端口222)
gitlab_rails['gitlab_ssh_host'] = '192.168.1.127'
gitlab_rails['gitlab_shell_ssh_port'] = 222 # 此端口是run时22端口映射的222端口
2.2 重启gitlab
改完配置需要重启。
[root@nb001 data]# docker restart gitlab
gitlab
三、访问
此时访问ip:8888无法访问,安全组也已经打开8888端口。发现是由于改了external_url 'http://192.168.1.127:8888’的端口为8888 后,gitlab容器的内部端口也被改为了8888,而我们在运行gitlab的时候,映射的是8888:80端口,故此时需要先stop容器,rm容器,然后重新以8888:8888的映射方式运行。
过程如下:
[root@nb001 data]# docker stop gitlab
gitlab
[root@nb001 data]# docker rm gitlab
gitlab
[root@nb001 data]# docker run --name gitlab --restart always -p 4433:443 -p 8888:8888 -p 222:22 -v /data/gitlab/config:/etc/gitlab -v /data/gitlab/logs:/var/log/gitlab -v /data/gitlab/data:/var/opt/gitlab -d gitlab/gitlab-ce
832f99c3e9085e1ecbf2f890d4821eed74238a76aa810ef27aed22759288f2d0
稍微等一会儿,报502也需要等一会,可以free -h查看下内存,如果内存充足,说明正在启动,等等就好。内存不足则。。。加呗。
出现如下界面表示OK
那么用户是什么呢?如下方式找root密码:
要快点找哦,这个密码听说是 24h 过期过期过期(最下面NOTE告诉你了)。所以需要登陆后修改一个新密码。
[root@nb001 logs]# docker exec -it gitlab bash
root@832f99c3e908:/# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: LanLz6ynObmHB+Oj2ttkhEDZc/uSMUYPoUC7dawQi3M=
# 翻译: 此文件将在24小时后的第一次重新配置运行中自动删除。
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
登录后:
完事就是建项目git的使用了。大家都会。
End
标签:Gitlab,8888,root,gitlab,端口,Docker,完整版,data,docker 来源: https://blog.csdn.net/wdy_2099/article/details/121486920