虚拟机centos安装kooder

前天在群晖上安装了一个gitlab,在github上拉了一些项目,想着搜索项目中代码的内容,但是问题就出现了,搜索只能搜项目名和简介。难道要把所有项目拉下来搜索?于是在网上找解决方案,就找到了kooder。

Kooder 是一个开源的代码搜索工具,目标是为包括 Gitee/GitLab/Gitea 在内的代码托管系统提供 自动的源码、仓库和 Issue 的搜索服务。

Kooder ScreenShot
搜索界面效果

于是跟着kooder的介绍文档,开始折腾了两天,这里把碰到的一些坑记录一下,方便以后查阅。

一、 创建centos7虚拟机

首先复制一个centos7的虚拟机,然后创建一个快照(最好创一个快照,方便折腾错了,可以及时恢复)。群晖上也有docker,为什么不用?一方面,群晖上的docker是图形化的(也可以用ssh,但是我怕把其他数据折腾坏了),遇到问题解决不灵活。另一方面,对docker还不熟悉,顺便学习一下。

二、升级centos内核(非必须)

为什么要升级centos内核呢?因为碰了坑,用老内核版本,安装新的docker,然后容器内和外面的网络不通。这种情况,还是在网上一篇文章里,作者说阿里云的工程师通过分析日志找出的原因。当然可能是我的centos7内核版本太低的原因,用的还是好几年的镜像文件,如果你系统内核版本较新,这一步可以忽略。

参考文章:centos7中docker网络docker0与容器间网络不通的坑

虚拟机centos安装kooder
文章内容
虚拟机centos安装kooder
容器内无法连接网络的情况

查看内核版本:
uname -r

[root@localhost docker]# uname -r
3.10.0-327.el7.x86_64

升级完后的内核版本

[root@localhost ~]# uname -r
5.16.14-1.el7.elrepo.x86_64

升级方法参考另一篇文章:Centos7 升级内核版本(转)

三、安装docker

1. 把yum包更新到最新

yum update
[root@localhost ~]# yum update
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * elrepo: hkg.mirror.rackspace.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.163.com
No packages marked for update

2. 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

yum install -y yum-utils device-mapper-persistent-data lvm2 
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * elrepo: hkg.mirror.rackspace.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.163.com
软件包 device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 已安装并且是最新版本
软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 安装
--> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要
--> 正在处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要
--> 正在检查事务
---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7_9.6 将被 安装
---> 软件包 python-kitchen.noarch.0.1.1.1-5.el7 将被 安装
--> 正在处理依赖关系 python-chardet,它被软件包 python-kitchen-1.1.1-5.el7.noarch 需要
--> 正在检查事务
---> 软件包 python-chardet.noarch.0.2.2.1-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================================
 Package                                 架构                            版本                                       源                                大小
===========================================================================================================================================================
正在安装:
 yum-utils                               noarch                          1.1.31-54.el7_8                            base                             122 k
为依赖而安装:
 libxml2-python                          x86_64                          2.9.1-6.el7_9.6                            updates                          247 k
 python-chardet                          noarch                          2.2.1-3.el7                                base                             227 k
 python-kitchen                          noarch                          1.1.1-5.el7                                base                             267 k

事务概要
===========================================================================================================================================================
安装  1 软件包 (+3 依赖软件包)

总下载量:863 k
安装大小:4.3 M
Downloading packages:
(1/4): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm                                                                                    | 247 kB  00:00:00     
(2/4): python-kitchen-1.1.1-5.el7.noarch.rpm                                                                                        | 267 kB  00:00:00     
(3/4): python-chardet-2.2.1-3.el7.noarch.rpm                                                                                        | 227 kB  00:00:00     
(4/4): yum-utils-1.1.31-54.el7_8.noarch.rpm                                                                                         | 122 kB  00:00:01     
-----------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                       446 kB/s | 863 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : python-chardet-2.2.1-3.el7.noarch                                                                                                      1/4 
  正在安装    : python-kitchen-1.1.1-5.el7.noarch                                                                                                      2/4 
  正在安装    : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                                  3/4 
  正在安装    : yum-utils-1.1.31-54.el7_8.noarch                                                                                                       4/4 
  验证中      : python-kitchen-1.1.1-5.el7.noarch                                                                                                      1/4 
  验证中      : yum-utils-1.1.31-54.el7_8.noarch                                                                                                       2/4 
  验证中      : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                                  3/4 
  验证中      : python-chardet-2.2.1-3.el7.noarch                                                                                                      4/4 

已安装:
  yum-utils.noarch 0:1.1.31-54.el7_8                                                                                                                       

作为依赖被安装:
  libxml2-python.x86_64 0:2.9.1-6.el7_9.6               python-chardet.noarch 0:2.2.1-3.el7               python-kitchen.noarch 0:1.1.1-5.el7              

完毕!

3. 设置yum源

yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
[root@localhost ~]# yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror
adding repo from: http://download.docker.com/linux/centos/docker-ce.repo
grabbing file http://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

4. 可以查看所有仓库中所有docker版本,并选择特定版本安装。(非必需)

[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror
已安装的软件包
可安装的软件包
 * updates: mirrors.163.com
Loading mirror speeds from cached hostfile
 * extras: mirrors.aliyun.com
 * elrepo: hkg.mirror.rackspace.com
docker-ce.x86_64            3:20.10.9-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.8-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.7-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.6-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.3-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.2-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.1-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.13-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:20.10.13-3.el7                   @docker-ce-stable
docker-ce.x86_64            3:20.10.12-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:20.10.11-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:20.10.10-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:20.10.0-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.9-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.8-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.7-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.6-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.3-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.2-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.15-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:19.03.14-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:19.03.1-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.13-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:19.03.12-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:19.03.11-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:19.03.10-3.el7                   docker-ce-stable 
docker-ce.x86_64            3:19.03.0-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.9-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.8-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.7-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.6-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.3-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.2-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.1-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.0-3.el7                    docker-ce-stable 
docker-ce.x86_64            18.06.3.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.06.2.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.06.1.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.06.0.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.03.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            18.03.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.12.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.12.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.3.ce-1.el7                   docker-ce-stable 
docker-ce.x86_64            17.03.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable 
 * base: mirrors.aliyun.com

5. 首先删除旧的docker,否则会报错。

yum remove docker  docker-common docker-selinux docker-engine
[root@localhost ~]# yum remove docker  docker-common docker-selinux docker-engine
已加载插件:fastestmirror
参数 docker 没有匹配
参数 docker-common 没有匹配
参数 docker-selinux 没有匹配
参数 docker-engine 没有匹配
不删除任何软件包

6. 安装docker

# 安装指定版本的docker
yum install docker-ce-19.03.9

# 安装最新版本的docker
yum install docker-ce
[root@localhost ~]# yum install docker-ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * elrepo: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.20.10.13-3.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 3:docker-ce-20.10.13-3.el7.x86_64 需要
--> 正在处理依赖关系 containerd.io >= 1.4.1,它被软件包 3:docker-ce-20.10.13-3.el7.x86_64 需要
--> 正在处理依赖关系 libseccomp >= 2.3,它被软件包 3:docker-ce-20.10.13-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-20.10.13-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.13-3.el7.x86_64 需要
--> 正在处理依赖关系 libcgroup,它被软件包 3:docker-ce-20.10.13-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
--> 正在处理依赖关系 policycoreutils-python,它被软件包 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 需要
---> 软件包 containerd.io.x86_64.0.1.5.10-3.1.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.20.10.13-3.el7 将被 安装
--> 正在处理依赖关系 docker-scan-plugin(x86-64),它被软件包 1:docker-ce-cli-20.10.13-3.el7.x86_64 需要
---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.13-3.el7 将被 安装
--> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-20.10.13-3.el7.x86_64 需要
--> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-20.10.13-3.el7.x86_64 需要
---> 软件包 libcgroup.x86_64.0.0.41-21.el7 将被 安装
---> 软件包 libseccomp.x86_64.0.2.3.1-4.el7 将被 安装
--> 正在检查事务
---> 软件包 docker-scan-plugin.x86_64.0.0.17.0-3.el7 将被 安装
---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
---> 软件包 policycoreutils-python.x86_64.0.2.5-34.el7 将被 安装
--> 正在处理依赖关系 setools-libs >= 3.3.8-4,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libsemanage-python >= 2.5-14,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 audit-libs-python >= 2.1.3-4,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 python-IPy,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.4)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.2)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4(VERS_4.0)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 checkpolicy,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1()(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4()(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装
--> 正在检查事务
---> 软件包 audit-libs-python.x86_64.0.2.8.5-4.el7 将被 安装
---> 软件包 checkpolicy.x86_64.0.2.5-8.el7 将被 安装
---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装
---> 软件包 libsemanage-python.x86_64.0.2.5-14.el7 将被 安装
---> 软件包 python-IPy.noarch.0.0.75-6.el7 将被 安装
---> 软件包 setools-libs.x86_64.0.3.3.8-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================================
 Package                                     架构                     版本                                        源                                  大小
===========================================================================================================================================================
正在安装:
 docker-ce                                   x86_64                   3:20.10.13-3.el7                            docker-ce-stable                    22 M
为依赖而安装:
 audit-libs-python                           x86_64                   2.8.5-4.el7                                 base                                76 k
 checkpolicy                                 x86_64                   2.5-8.el7                                   base                               295 k
 container-selinux                           noarch                   2:2.119.2-1.911c772.el7_8                   extras                              40 k
 containerd.io                               x86_64                   1.5.10-3.1.el7                              docker-ce-stable                    30 M
 docker-ce-cli                               x86_64                   1:20.10.13-3.el7                            docker-ce-stable                    30 M
 docker-ce-rootless-extras                   x86_64                   20.10.13-3.el7                              docker-ce-stable                   8.1 M
 docker-scan-plugin                          x86_64                   0.17.0-3.el7                                docker-ce-stable                   3.7 M
 fuse-overlayfs                              x86_64                   0.7.2-6.el7_8                               extras                              54 k
 fuse3-libs                                  x86_64                   3.6.1-4.el7                                 extras                              82 k
 libcgroup                                   x86_64                   0.41-21.el7                                 base                                66 k
 libseccomp                                  x86_64                   2.3.1-4.el7                                 base                                56 k
 libsemanage-python                          x86_64                   2.5-14.el7                                  base                               113 k
 policycoreutils-python                      x86_64                   2.5-34.el7                                  base                               457 k
 python-IPy                                  noarch                   0.75-6.el7                                  base                                32 k
 setools-libs                                x86_64                   3.3.8-4.el7                                 base                               620 k
 slirp4netns                                 x86_64                   0.4.3-4.el7_8                               extras                              81 k

事务概要
===========================================================================================================================================================
安装  1 软件包 (+16 依赖软件包)

总计:96 M
总下载量:22 M
安装大小:388 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
警告:/var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.13-3.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY0:00:05 ETA 
docker-ce-20.10.13-3.el7.x86_64.rpm 的公钥尚未安装
docker-ce-20.10.13-3.el7.x86_64.rpm                                                                                                 |  22 MB  00:00:04     
从 https://download.docker.com/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://download.docker.com/linux/centos/gpg
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libseccomp-2.3.1-4.el7.x86_64                                                                                                         1/17 
  正在安装    : docker-scan-plugin-0.17.0-3.el7.x86_64                                                                                                2/17 
  正在安装    : 1:docker-ce-cli-20.10.13-3.el7.x86_64                                                                                                 3/17 
  正在安装    : libcgroup-0.41-21.el7.x86_64                                                                                                          4/17 
  正在安装    : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                      5/17 
  正在安装    : setools-libs-3.3.8-4.el7.x86_64                                                                                                       6/17 
  正在安装    : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                  7/17 
  正在安装    : checkpolicy-2.5-8.el7.x86_64                                                                                                          8/17 
  正在安装    : python-IPy-0.75-6.el7.noarch                                                                                                          9/17 
  正在安装    : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                        10/17 
  正在安装    : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                  11/17 
  正在安装    : libsemanage-python-2.5-14.el7.x86_64                                                                                                 12/17 
  正在安装    : policycoreutils-python-2.5-34.el7.x86_64                                                                                             13/17 
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                   14/17 
  正在安装    : containerd.io-1.5.10-3.1.el7.x86_64                                                                                                  15/17 
  正在安装    : docker-ce-rootless-extras-20.10.13-3.el7.x86_64                                                                                      16/17 
  正在安装    : 3:docker-ce-20.10.13-3.el7.x86_64                                                                                                    17/17 
  验证中      : libsemanage-python-2.5-14.el7.x86_64                                                                                                  1/17 
  验证中      : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                         2/17 
  验证中      : containerd.io-1.5.10-3.1.el7.x86_64                                                                                                   3/17 
  验证中      : 1:docker-ce-cli-20.10.13-3.el7.x86_64                                                                                                 4/17 
  验证中      : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                   5/17 
  验证中      : 3:docker-ce-20.10.13-3.el7.x86_64                                                                                                     6/17 
  验证中      : docker-ce-rootless-extras-20.10.13-3.el7.x86_64                                                                                       7/17 
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                    8/17 
  验证中      : python-IPy-0.75-6.el7.noarch                                                                                                          9/17 
  验证中      : libseccomp-2.3.1-4.el7.x86_64                                                                                                        10/17 
  验证中      : checkpolicy-2.5-8.el7.x86_64                                                                                                         11/17 
  验证中      : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                     12/17 
  验证中      : policycoreutils-python-2.5-34.el7.x86_64                                                                                             13/17 
  验证中      : docker-scan-plugin-0.17.0-3.el7.x86_64                                                                                               14/17 
  验证中      : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                 15/17 
  验证中      : setools-libs-3.3.8-4.el7.x86_64                                                                                                      16/17 
  验证中      : libcgroup-0.41-21.el7.x86_64                                                                                                         17/17 

已安装:
  docker-ce.x86_64 3:20.10.13-3.el7                                                                                                                        

作为依赖被安装:
  audit-libs-python.x86_64 0:2.8.5-4.el7            checkpolicy.x86_64 0:2.5-8.el7               container-selinux.noarch 2:2.119.2-1.911c772.el7_8       
  containerd.io.x86_64 0:1.5.10-3.1.el7             docker-ce-cli.x86_64 1:20.10.13-3.el7        docker-ce-rootless-extras.x86_64 0:20.10.13-3.el7        
  docker-scan-plugin.x86_64 0:0.17.0-3.el7          fuse-overlayfs.x86_64 0:0.7.2-6.el7_8        fuse3-libs.x86_64 0:3.6.1-4.el7                          
  libcgroup.x86_64 0:0.41-21.el7                    libseccomp.x86_64 0:2.3.1-4.el7              libsemanage-python.x86_64 0:2.5-14.el7                   
  policycoreutils-python.x86_64 0:2.5-34.el7        python-IPy.noarch 0:0.75-6.el7               setools-libs.x86_64 0:3.3.8-4.el7                        
  slirp4netns.x86_64 0:0.4.3-4.el7_8               

完毕!

7. 没启动docker之前查看docker版本

[root@localhost ~]# docker -v
Docker version 20.10.13, build a224086
[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.13
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 10 14:09:51 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

8. 启动docker之后查看docker版本

启动docker

# 启动docker
systemctl start docker
# 允许开机启动
systemctl enable docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.13
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 10 14:09:51 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.13
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       906f57f
  Built:            Thu Mar 10 14:08:16 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.10
  GitCommit:        2a1d4dbdb2a1030dc5b01e96fb110a9d9f150ecc
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

9. 通过运行 hello-world 映像来验证是否正确安装了 Docker

docker run hello-world
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:4c5f3db4f8a54eb1e017c385f683a2de6e06f75be442dc32698c9bbe6c861edd
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

10. 查看容器情况

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED          STATUS                      PORTS     NAMES
a7488ccf35f5   hello-world   "/hello"   31 seconds ago   Exited (0) 28 seconds ago             ecstatic_blackburn

11. 卸载 docker(留作删除操作)

删除安装包:

yum remove docker-ce

删除镜像、容器、配置文件等内容:

rm -rf /var/lib/docker

四、安装docker-compose

1. 下载的docker-compose文件

# 1.29.2是版本号
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# 若是github访问太慢,可以用daocloud下载
sudo curl -L "https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. 添加可执行权限

sudo chmod +x /usr/local/bin/docker-compose

3. 查看 docker-compose 版本,测试安装结果

docker-compose --version
[root@localhost ~]# sudo curl -L "https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0    372      0  0:00:01  0:00:01 --:--:--   372
100 12.1M  100 12.1M    0     0  1469k      0  0:00:08  0:00:08 --:--:-- 3290k
[root@localhost ~]# sudo chmod +x /usr/local/bin/docker-compose
[root@localhost ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c

五、安装kooder

1.安装git

# 安装git
yum install git

# 查看git版本
git --version

2. 拉取代码

在hone下建一个docker文件夹,用来存放docker项目文件,在docker文件夹下拉取kooder项目

git clone https://gitee.com/koode/kooder.git

打开kooder文件夹

[root@localhost ~]# cd /home/docker
[root@localhost docker]# git clone https://gitee.com/koode/kooder.git
正克隆到 'kooder'...
remote: Enumerating objects: 6870, done.
remote: Counting objects: 100% (57/57), done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 6870 (delta 14), reused 27 (delta 9), pack-reused 6813
接收对象中: 100% (6870/6870), 4.79 MiB | 1.11 MiB/s, done.
处理 delta 中: 100% (3250/3250), done.
[root@localhost docker]# cd kooder/
[root@localhost kooder]# ls
bin   docker-compose-ha.yaml  Dockerfile  gateway      indexer            LICENSE  README.md
core  docker-compose.yaml     docs        haproxy.cfg  kooder.properties  pom.xml  README.zh-CN.md
[root@localhost docker]# cd kooder/

3. 一键启动kooder容器( docker-compose 会根据配置文件自动拉取镜像,配置容器信息)

docker-compose up -d 
[root@localhost kooder]# docker-compose up -d 
Pulling kooder (registry.cn-hangzhou.aliyuncs.com/devops_hu/kooder:v1.0.1)...
v1.0.1: Pulling from devops_hu/kooder
e519532ddf75: Pull complete
b9df0e035773: Pull complete
6f7826f634eb: Pull complete
f55cb44d8d57: Pull complete
92d789fbe5d6: Pull complete
a3fc5ad992fb: Pull complete
73fa4b54ede1: Pull complete
4db4f3d8b907: Pull complete
4045b7742c82: Pull complete
99155f8605a3: Pull complete
Digest: sha256:617d55ad760a75cda799ef1946087d8741c5761a8a84f179136984ab6d86d8cd
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/devops_hu/kooder:v1.0.1
Creating kooder ... done

查看docker容器状态

虚拟机centos安装kooder

启动成功,查看一下docker日志,最好新开一个终端中查看。

# 59f90cdb87f1容器id,即上面容器状态中的CONTAINER ID。

docker logs -f 59f90cdb87f1
虚拟机centos安装kooder
kooder启动日志

通过日志可以得知,kooder有报错,gitlab信息初始错误,这是因为我们用的是项目中的默认配置文件,信息和我们的环境不一样。

4.修改kooder配置信息

vi  /home/docker/kooder/kooder.properties

下面是我这边的配置

# Gitee Search

# Gitee Search Gateway configurations
# 192.168.31.23是我kooder虚拟机的ip
http.url = http://192.168.31.23:8080
http.bind =
http.port = 8080
http.log = on
http.webroot = gateway/src/main/webapp
http.startup.tasks = indexer,gitlab

#file.index.path = d://file.txt
#file.index.vender =

# gitlab setting
# 192.168.31.247:1088是我gitliab的ip和端口
gitlab.url = http://192.168.31.247:1088/
gitlab.personal_access_token = ouV227Kjijg4cBkJgRJ3
gitlab.secret_token = gsearch
gitlab.connect_timeout = 2000
gitlab.read_timeout = 10000

# gitee setting
#gitee.url = http://giteehost/
#gitee.personal_access_token = bb319595dc98bb8fbdcf3fc442c25893

# Git
# git.username git.password是我gitlab的root账号密码
git.username = root
git.password = admin1234
# git.ssh.key = ./data/ssh_key
# git.ssh.keypass =

#
queue.provider = embed
queue.types = repo,issue,code
queue.redis.host = 127.0.0.1
queue.redis.port = 6379
queue.redis.database = 1
queue.redis.key = gsearch-queue

# queue.embed.url = http://127.0.0.1:8080/queue/fetch
queue.embed.path = ./data/queue
queue.embed.batch_size = 10000

#
storage.type = disk
storage.disk.path = ./data/lucene
storage.disk.use_compound_file = false
storage.disk.max_buffered_docs = -1
storage.disk.ram_buffer_size_mb = 16

#
storage.repositories.path = ./data/repositories
storage.repositories.max_size_in_gigabyte = 200


indexer.no_task_interval = 1000
indexer.batch_fetch_count = 10
indexer.tasks_per_thread = 2

编辑完后在kooder的容器中,重新构建并运行kooder

# 进入kooder容器
docker exec -it 59f90cdb87f1 /bin/bash

mvn install

# 启动 gateway
bin/gateway.sh

如果不能kooder运行,则重启docker 容器

docker restart 59f90cdb87f1

5. kooder配置信息说明

1. gitlab.personal_access_token

虚拟机centos安装kooder
虚拟机centos安装kooder

这里提交后,会生成一个令牌,就是gitlab.personal_access_token

虚拟机centos安装kooder

2. gitlab. secret_token

虚拟机centos安装kooder
虚拟机centos安装kooder

这个好像kooder会创建过来,不确定不添加会不会有问题,已经折腾几天了不想去试了。

3. 注意一定要给gitlab配置ip地址,不然kooder获取项目代码时会报错,无法获取项目代码。

虚拟机centos安装kooder
gitliab不配置ip或域名,kooder报错日志

gitlab配置ip或域名方式

# 在你的gitlab服务器,编辑这个文件
vi /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

# 修改gitlab下host值为实际的域名或服务器IP地址即可,保存退出
gitlab-ctl restart

六、运行效果图

虚拟机centos安装kooder
成功获取项目信息的kooder日志
虚拟机centos安装kooder
代码搜索结果图

参考资料

本次主要参考以下资料,在此表示衷心感谢!

1.kooder项目说明文档
https://gitee.com/koode/kooder

2.Docker网桥模式ping不通宿主机
https://blog.csdn.net/qq_36059826/article/details/106550332

3.centos7中docker网络docker0与容器间网络不通的坑
https://blog.csdn.net/weixin_42288415/article/details/105366176

4.centos7安装docker和docker-compose
https://www.cnblogs.com/eternityz/p/13264980.html

5.centos 安装:docker-compose
https://blog.csdn.net/weixin_39709920/article/details/123147742

6.Docker 容器使用
https://www.runoob.com/docker/docker-container-usage.html

7.GitLab—URL服务器IP地址设置
https://www.cnblogs.com/walkersss/p/15508641.html

原创文章,作者:Zeyu,如若转载,请注明出处:https://jinzhijun.cn/develop/1036

(0)
ZeyuZeyu
上一篇 2022年3月13日 下午11:01
下一篇 2022年4月8日 下午5:56

相关推荐

  • vmware最小安装centos并配置固定本地固定ip

    最近公司互联网医院的接入工作差不多进入了尾声,接下来就是整理一些资料什么的,所以有些空闲时间,想着学一下swoole,然后就碰到了安装虚拟机的问题。之前也装过很多次,但是每次安装都…

    2021年8月16日
    1.8K
  • 网站防DDOS攻击思路

    最近给一个客户搭的网站,受到DDOS攻击,因为源码是在网上找的,代码质量不忍直视,一个首页就有n条sql查询。虽然服务器配置用了8核8G内存,然后也加了阿里云全站加速(过滤了一些流…

    2022年9月5日
    2.8K
  • 阿里云OSS图片上传与加水印签名访问

    最近公司的一个系统有一个需求,因为公司的产品有一些特殊性,经常有可能会被同行盗图,所以需要将所有的产品图片加水印展示。但是还有一个需求,内部人员可能需要查看原图,所以,这个就有点奇…

    2021年4月30日
    4.6K
  • 使用 Laravel 开发 API 时的前置准备(转)

    一、前言 使用 Laravel 有一段时间了,虽然公司项目使用的都是 Thinkphp 框架,但我个人还是比较偏好 Laravel,今天来总结我平时进行开发前的一些准备工作,如果有…

    2022年7月15日
    3.3K
  • Centos7 升级内核版本(转)

    1、查看当前内核版本 [root@localhost ~]# uname -r 3.10.0-327.el7.x86_64 [root@localhost ~]# uname -a…

    2022年3月13日
    1.4K
  • PHP代码审计一条龙思路(转)

    00×0 前言 最近也是边挖src边审计代码,总结下最近的php代码审计的一些思路,我一般按照顺序往下做,限于能力水平,可能会有不对或者欠缺的地方,希望各位师傅能够指导。 00×1…

    2022年5月31日
    1.4K
  • 广东省互联网医院接入——远程确认

    今天公司互联网医院接入终于走到了远程确认这一步了,因为一直是摸着石头过河,中间做了不少弯路,这里做个记录,希望也在摸索的同行如果看到能有一个参考。当然写这个的时候,还只是远程演示了…

    技术开发 2021年8月18日
    1.3K
  • php实现助记词转TRX,ETH 私钥和钱包地址

    TRX助记词转地址网上都是Java,js或其他语言开发的示例,一个简单的功能需要依赖其他环境来实现表示不能忍,毕竟php是世界上最好的语言。【狗头】 一、知识准备 要实现助记词转T…

    2022年8月4日
    7.8K
  • codeigniter发邮件sendmail报错

    最近将公司系统从Windows换成了Linux,大部分功能都能正常使用,唯独发送邮件通知功能时,出现了错误。通过var_dump($CI->email->print_d…

    2020年11月12日
    1.6K
  • window配置Vue2开发环境

    最近找到一套互联网医院的源码,前端技术栈用的是vue,于是想着把vue开发环境搭起来,在网上找了一点资料,现在总结记录一下,方便以后查阅。 一、介绍 Vue (读音 /v…

    2020年10月17日
    1.6K

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注