12.docker搭建gitlab

docker搭建gitlab

创建宿主机挂载目录

由于是docker镜像运行, 所以我们需要把gitlab的
配置, 数据, 日志存到容器外面, 即将其挂载到宿主机。先准备三个目录:


[root@localhost ~]# cd /srv
[root@localhost srv]# mkdir gitlab
[root@localhost srv]# cd gitlab
[root@localhost gitlab]# ls
[root@localhost gitlab]# mkdir config logs data
[root@localhost gitlab]# ls
config  data  logs

拉取镜像


[root@localhost gitlab]# docker pull gitlab/gitlab-ce
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
16ec32c2132b: Pull complete
a3ffc39dc4a2: Pull complete
fb4084b9c931: Pull complete
19d626b4945e: Pull complete
f9bb9f2afcb2: Pull complete
bb4963790296: Pull complete
da7df64f6f8a: Pull complete
cfa12a8835f4: Pull complete
Digest: sha256:515ff158992ac63b55b0a5f658db14428dd82403dd8b228ff82678723062fc79
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest

创建容器

docker run --detach --publish 443:443 --
publish 9001:80 --publish 8022:22 --
hostname 虚拟机的Ip --name mygitlab --
restart always -v
/srv/gitlab/config:/etc/gitlab -v
/srv/gitlab/logs:/var/log/gitlab -v
/srv/gitlab/data:/var/opt/gitlab -v
/etc/localtime:/etc/localtime:ro --
privileged=true gitlab/gitlab-ce


docker run -di --publish 443:443 --publish 9001:80 --publish 8022:22 --hostname 192.168.222.128 --name mygitlab --restart always -v /srv/gitlab/config:/etc/gitlab -v /srv/gitlab/logs:/var/log/gitlab -v /srv/gitlab/data:/var/opt/gitlab -v /etc/localtime:/etc/localtime:ro --privileged=true gitlab/gitlab-ce

[root@localhost gitlab]# docker run -di --publish 443:443 --publish 9001:80 --publish 8022:22 --hostname 192.168.222.128 --name mygitlab > --restart always -v > /srv/gitlab/config:/etc/gitlab -v > /srv/gitlab/logs:/var/log/gitlab -v > /srv/gitlab/data:/var/opt/gitlab -v > /etc/localtime:/etc/localtime:ro --privileged=true gitlab/gitlab-ce
00f2fda383598aabd32271dd797a16c63909452d790755fa5c54b91f28d48474


[root@localhost gitlab]# docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED          STATUS                             PORTS                                                                                                                 NAMES
00f2fda38359   gitlab/gitlab-ce       "/assets/wrapper"        54 seconds ago   Up 52 seconds (health: starting)   0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:8022->22/tcp, :::8022->22/tcp, 0.0.0.0:9001->80/tcp, :::9001->80/tcp   mygitlab

访问gitlab

输入IP和端口直接访问

获取默认密码

使用默认密码登录

gitlab-ce-14初装以后,把密码放在了一个临时文件中了
/etc/gitlab/initial_root_password
这个文件将在首次执行reconfigure后24小时自动删除

我做了挂载映射
[root@localhost ~]# cd /srv/gitlab/config

[root@localhost config]# cat 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: PG11oMOtejZK8HUIlWv140dc3VN+JBpLE1xE6LFga1I=

修改密码

12.docker搭建gitlab

12.docker搭建gitlab

输入密码,点击change
12.docker搭建gitlab

重新使用新密码登录
12.docker搭建gitlab

登录成功

注册新用户

12.docker搭建gitlab

You have signed up successfully. However, we could not sign you in because your account is awaiting approval from your GitLab administrator.

新用户登录报错解决:
使用root登录,进行审批通过就可以

12.docker搭建gitlab

12.docker搭建gitlab

再次使用新用户登录成功

12.docker搭建gitlab

502解决方案:

502
Whoops, GitLab is taking too much time to respond.
Try refreshing the page, or going back and attempting the action again.

Please contact your GitLab administrator if this problem persists.

Go back

12.docker搭建gitlab

docker exec 77(容器id) gitlab-ctl reconfigure#容器里启动服务

防火墙根据情况来选择
systemctl stop firewalld#关闭防火墙

12.docker搭建gitlab

上一篇:OpenStack各组件的常用命令


下一篇:HBASE搭建