x86下中标麒麟的docker安装

环境:x86架构,neokylin-release7.6,本质还是centos。

# uname -a
Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Fri Jan 11 17:34:50 CST 2019 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
bugtracker_url = http://bugzilla.cs2c.com.cn/bugzilla
distroverpkg=neokylin-release

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
# cat /etc/os-release 
NAME="NeoKylin Linux Advanced Server"
VERSION="V7Update6 (Chromium)"
ID="neokylin"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="V7Update6"
PRETTY_NAME="NeoKylin Linux Advanced Server V7Update6 (Chromium)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:neokylin:enterprise_linux:V7Update6:GA:server"
HOME_URL="https://www.cs2c.com.cn/"
BUG_REPORT_URL="https://bugzilla.cs2c.com.cn/"

NEOKYLIN_BUGZILLA_PRODUCT="NeoKylin Linux Advanced Server 7"
NEOKYLIN_BUGZILLA_PRODUCT_VERSION=V7Update6
NEOKYLIN_SUPPORT_PRODUCT="NeoKylin Linux Advanced Server"
NEOKYLIN_SUPPORT_PRODUCT_VERSION="V7Update6"

在线安装

先测试了一下在线安装。先上官网安装教程:Install Docker Engine on CentOS | Docker Documentation

这里采用的是仓库安装(和rpm包其实是一个效果,仓库装报错,rpm一样报错)在安装yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin时出现了两个问题:

官方和阿里的云都报错[Errno 14] HTTP Error 404 - Not Found

查了仓库源码,发现是releasever取的是yum.conf中distroverpkg配置的值,查看如下:

docker-ce.repo

# rpm -qi neokylin-release-server 
Name        : neokylin-release-server
Version     : 7.6
Release     : 4.el7.ns7.05.lic.adv
Architecture: x86_64
Install Date: 2022年05月30日 星期一 11时16分03秒
Group       : System Environment/Base
Size        : 33767
License     : GPLv2
Signature   : RSA/SHA1, 2019年08月20日 星期二 07时46分06秒, Key ID 41f8aebe7a486d9f
Source RPM  : neokylin-release-server-7.6-4.el7.ns7.05.lic.adv.src.rpm
Build Date  : 2019年08月20日 星期二 07时46分03秒
Build Host  : localhost
Relocations : (not relocatable)
Packager    : NeoKylin Linux
Vendor      : CS2C
Summary     : NeoKylin Linux Advanced Server release file
Description :
NeoKylin Linux Advanced Server release files

因此,releasever最后的结果是Version+Release的组合7.6-4.el7.ns7.05.lic.adv,导致无法找到,奇怪的是,本来应该只取Version的,不知为何这中标麒麟也加上了release,无奈之下,手动改了源的releasever变量替换为固定的7.6,vim命令:%s/$releasever/7.6/g,结果如下:

# cat /etc/yum.repos.d/docker-ce.repo 
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.6/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

此时这个404的问题就消失了。

第二个问题,发现container-selinux的依赖过低,本地是2.55,需要2.74

reference

这是由于系统缺乏必要的依赖,只能手动安装,自动安装是没有用的,对于

错误:软件包:containerd.io-1.6.4-3.1.el7.x86_64 (docker-ce-stable)
          需要:container-selinux >= 2:2.74
          已安装: 2:container-selinux-2.55-1.el7.noarch (@ns7-adv-os)
              container-selinux = 2:2.55-1.el7

需要先卸载低版本的,在安装高版本的。另外的slirp4netns和fuse-overlayfs不用卸载,直接安装即可。另外,fuse-overlayfs还依赖一个fuse3-libs,这个直接在centos7.6的包里下载最新的即可。阿里云镜像地址:centos-7-extras-x86_64-Packages安装包下载_开源镜像站-阿里云 (aliyun.com)

# rpm -ivh fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm 
警告:fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        libfuse3.so.3()(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(FUSE_3.2)(64bit) 被 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要

最后需要下载的包如下:

# ll
总用量 264
-rw-r--r-- 1 root root 40816 7月   6 2020 container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
-rw-r--r-- 1 root root 83764 4月  29 2020 fuse3-libs-3.6.1-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 55796 4月  29 2020 fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
-rw-r--r-- 1 root root 83452 4月  29 2020 slirp4netns-0.4.3-4.el7_8.x86_64.rpm

下载命令: wget xxx.rpm
安装命令: rpm -ivh xxx.rpm

一键安装

以上两个问题解决后,一键安装并启动、设置自动重启就大功告成了。

yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl start docker
systemctl enable docker

看一下版本号:

# docker version
Client: Docker Engine - Community
 Version:           20.10.16
 API version:       1.41
 Go version:        go1.17.10
 Git commit:        aa7e414
 Built:             Thu May 12 09:19:45 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.16
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.10
  Git commit:       f756502
  Built:            Thu May 12 09:18:08 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.4
  GitCommit:        212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
 runc:
  Version:          1.1.1
  GitCommit:        v1.1.1-0-g52de29d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

跑一个hello world试试:

# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:80f31da1ac7b312ba29d65080fddf797dd76acfb870e677f390d5acba9741b17
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/

离线安装

你可能感兴趣的:(x86下中标麒麟的docker安装)