Docker目前支持Centos 7及以后版本的操作系统,内核版本至少要求3.10。

一、第一种安装方法

1、为了方便添加软件源,以及支持devicemapper存储类型,安装软件包

# yum install yum-utils device-mapper-persistent-data lvm2 -y


2、添加Docker稳定版本的yum软件源

# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo


3、清除yum缓存,并安装社区版本Docker软件

# yum clean all
# yum install docker-ce docker-ce-cli containerd.io -y


如果安装过程遇到类似如下警告,可以关闭docker-ce源的gpg验证

警告:/var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-cli-19.03.13-3.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY0:06 ETA
docker-ce-cli-19.03.13-3.el7.x86_64.rpm 的公钥尚未安装


关闭docker-ce源的gpg验证,将gpgcheck=1更改为gpgcheck=0。

# vi /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/$releasever/source/test
enabled=0
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg
 
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=0
gpgkey=https://download.docker.com/linux/centos/gpg


4、启动docker软件

# systemctl start docker

 

5、验证查看Docker版本信息

# docker version
Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:03:45 2020
 OS/Arch:           linux/amd64
 Experimental:      false
 
Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:02:21 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683


二、第二种方法通过脚本安装

# curl -fsSL https://get.docker.com/ | sh

 

列出可以安装的Docker版本

# yum list docker-ce --showduplicates | sort -r


点赞(374)

评论列表共有 0 条评论

立即
投稿
返回
顶部