官方教程 
https://docs.gitlab.com/omnibus/docker/

建议虚拟机内存2G以上

搜索镜像

docker search gitlab 

下载镜像文件

docker pull docker.io/gitlab/gitlab-ce


注意:一定要配置阿里云的加速镜像

                     创建GitLab 的配置 (etc) 、 日志 (log) 、数据 (data) 放到容器之外, 便于日后升级, 因此请先准备这三个目录。

mkdir -p /mnt/gitlab/etc
mkdir -p /mnt/gitlab/log
mkdir -p /mnt/gitlab/data

创建容器之前,我们先关闭下防火墙,重启docker服务

systemctl stop firewalld.service
firewall-cmd --state
systemctl daemon-reload
systemctl stop firewalld.service

运行GitLab容器 

docker run \
--detach \
--publish 2222:22 \
--publish 8090:80 \
--publish 8443:443 \
--hostname 192.168.56.3 \
-v /mnt/gitlab/etc:/etc/gitlab \
-v /mnt/gitlab/log:/var/log/gitlab \
-v /mnt/gitlab/data:/var/opt/gitla \
-v /etc/localtime:/etc/localtime:ro \
--name gitlab \
--restart always \
--privileged=true gitlab/gitlab-ce:latest

 运行成功之后,将挂载文件同步到容器外面

修改/mnt/gitlab/etc/gitlab.rb

把external_url改成部署机器的域名或者IP地址

vi /mnt/gitlab/etc/gitlab.rb

external_url 'http://192.168.56.3'

按 i 进行编辑,编辑好了按Esc,:wq 进行保存

修改/mnt/gitlab/data/gitlab-rails/etc/gitlab.yml

vi /mnt/gitlab/data/gitlab-rails/etc/gitlab.yml

找到关键字 * ## Web server settings *

按斜杠进行搜索

/Web server settings

我们进到目录再看一下挂载文件是否同步到外面来了

[root@localhost ~]# cd /mnt/gitlab/etc/
[root@localhost etc]# ls
gitlab.rb ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key trusted-certs
gitlab-secrets.json ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub

这个时候我们把容器停止再删除,然后重启服务

[root@localhost ~]# docker stop 3f3d49ac7888aaf51d51761c27f92e4bf1b465f76b1a58f3428637b9c3ffd9b7
3f3d49ac7888aaf51d51761c27f92e4bf1b465f76b1a58f3428637b9c3ffd9b7
[root@localhost ~]# docker rm 3f3d49ac7888aaf51d51761c27f92e4bf1b465f76b1a58f3428637b9c3ffd9b7
3f3d49ac7888aaf51d51761c27f92e4bf1b465f76b1a58f3428637b9c3ffd9b7
[root@localhost ~]# systemctl restart docker
[root@localhost ~]#

再来重新创建容器

docker run \
--detach \
--publish 2222:22 \
--publish 8090:80 \
--publish 8443:443 \
--hostname 192.168.56.3 \
-v /mnt/gitlab/etc:/etc/gitlab \
-v /mnt/gitlab/log:/var/log/gitlab \
-v /mnt/gitlab/data:/var/opt/gitla \
-v /etc/localtime:/etc/localtime:ro \
--name gitlab \
--restart always \
--privileged=true gitlab/gitlab-ce:latest

这个时候我们来查一下,看一下容器有没有分配ip地址,有的话表示创建容器成功了。

[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d07898b3749d gitlab/gitlab-ce "/assets/wrapper" About a minute ago Up Less than a second (health: starting) 22/tcp, 0.0.0.0:8090->80/tcp, 0.0.0.0:8443->443/tcp gitlab
f264e5f1be41 sonatype/nexus3 "sh -c ${SONATYPE_DI…" 2 hours ago Up 2 hours 0.0.0.0:8081->8081/tcp nexus
[root@localhost ~]# docker inspect d07898b3749d

访问一下ip地址

[root@localhost ~]# curl 172.17.0.3:80
curl: (7) Failed connect to 172.17.0.3:80; Connection refused

拒绝连接,说明启动没有那么快,还需要一些时间

关闭防火墙,查看下状态,这个时候防火墙已经关闭了。

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# firewall-cmd --state
not running
[root@localhost ~]#

查看了下容器状态,发现gitlab一直是重启状态

[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUSPORTS NAMES
d07898b3749d gitlab/gitlab-ce:latest "/assets/wrapper" 19 minutes ago Restarting (1) 1 second ago gitlab

查看日志

sudo docker logs gitlab

错误就不在这里演示了,通过谷歌解决了我的问题,

解决好之后重启下服务跟gitlab

重新验证,好了

等个几分钟,重新刷新下页面

至此gitlab搭建成功了,历经千辛万苦。

CentOS7-Docker 安装 Gitlab详细篇的更多相关文章

  1. Centos7 docker安装GitLab

    *先决条件系统已安装Docker 1.查询GitLab镜像 docker search gitlab 2.现在GitLab镜像 3.创建文件夹 mkdir -p /software/gitlab/co ...

  2. Docker安装Gitlab

    一.Ubuntu16.4上Docker安装Gitlab 1.安装docker 参见:https://docs.docker.com/engine/installation/linux/ubuntuli ...

  3. docker安装gitlab并部署CICD

    摘要 本文主要实现了在docker下安装gitlab,将gitlab绑定在宿主机的180端口,将gitlab的clone的URL添加指定端口号:部署了CI/CD,并公布了测试项目. 安装docker[ ...

  4. centos7 部署安装gitlab服务器

    概念: git 是一种版本控制系统,是一个命令,是一种工具 gitlib 是用于实现git功能的开发库 github 是一个基于git实现的在线代码托管仓库,包含一个网站界面,向互联网开放 gitla ...

  5. 解决 Windows Docker 安装 Gitlab Volume 权限问题

    本文首发于我的个人博客,解决 Windows Docker 安装 Gitlab Volume 权限问题 ,欢迎访问! 记录一下 Windows10 下 Docker 安装 Gitlab 的步骤. Ca ...

  6. CentOS7离线安装Nginx(详细安装过程)

    CentOS7离线安装Nginx(详细安装过程) 1.安装gcc.g++ 下载好所需的文件后上传至服务器(下载地址:https://download.csdn.net/download/a729360 ...

  7. 利用docker安装gitlab

    安装docker 安装 virtualbox 下载 dockertoolbox并安装 官网的服务器一直连不上, 幸亏还有这个 https://get.daocloud.io/toolbox/ 比 ht ...

  8. centos7.3 安装oracle 详细过程

    centos7.3安装oracle详细过程1.下载Oracle安装包:linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2 ...

  9. docker 安装gitlab

    # docker 安装gitlab # 一.安装镜像(官网文档) export GITLAB_HOME=/srv/gitlab # 必须先设置它,它就是你存储代码仓库的位置.以后要移植的时候直接把这个 ...

随机推荐

  1. 连root也干不掉的文件

    在你的印象中,是不是root用户就可以为所欲为呢?随便一个rm -rf *,一波骚操作走人?可能没那么容易. 来啊,删我啊! 先来个示例,创建一个文本文件test.txt $ touch test.t ...

  2. windows下使用ssh(利用paramiko库)

    环境:python3.7.3 win7 or win10 1.首先下载paramiko库 命令:pip install paramiko 2.代码: import paramiko 创建一个 ssh ...

  3. Tomcat服务器编码格式设置

    /** *1.找到.xml server文件 */ /** * 2. 设置encoding */

  4. Linux文件服务管理之vsftpd

    简介 vsftpd是 "very secure FTP deamon"的缩写,是一个完全免费,开源的ftp服务器软件. 特点 小巧轻快,安全易用,支持虚拟用户.支持带宽限制等功能. ...

  5. HTTP中分块编码(Transfer-Encoding: chunked)

    转自: 妙音天女--分块传输编码~ 参考链接: HTTP MDN--HTTP协议 一.背景: 持续连接的问题:对于非持续连接,浏览器可以通过连接是否关闭来界定请求或响应实体的边界:而对于持续连接,这种 ...

  6. Jupyter 中的 10 个魔法函数

    1)%pwd 于显示Jupyter当前的工作空间. 2)%hist 显示当前Jupyter中,所有运行过的历史代码. 3)%who 显示当前Jupyter环境中的所有变量或名称. 4)%reset 删 ...

  7. Manacher算法(马拉车)求最长回文子串

    Manacher算法求最长回文字串 算法思路 按照惯例((・◇・)?),这里只是对算法的一些大体思路做一个描述,因为找到了相当好理解的博客可以参考(算法细节见参考文章). 一般而言,我们的判断回文算法 ...

  8. 数据结构 - 二叉搜索树封装 C++

    二叉搜索树封装代码 #pragma once #include <iostream> using namespace std; template<class T>class T ...

  9. oneinstack——证书更新

    如果你安装好 oneinstack 你的定时任务就会自动添加 "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh ...

  10. PyCharm编写的代码生成可执行文件操作步骤

    1.打开Pycharm.2.打开Terminal(快捷键Alt + F12) 3.安装pyinstaller工具输入:pip install pyinstaller4.生成本项目可执行文件Termin ...