docker下载地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
分别下载以下包:
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.9-3.el7.x86_64.rpm
docker卸载
Uninstall old versions
Older versions of Docker were called docker
or docker-engine
. If these are installed, uninstall them, along with associated dependencies.
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
Uninstall the Docker package:
$ sudo yum remove docker-ce
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
$ sudo rm -rf /var/lib/docker
docker安装:
[root@otc-web ~]# rpm -ivh container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:container-selinux-2.119.1-1.c57a6f9.el7.noarch
################################# [100%]
container-selinux >= 2.9
这个报错是container-selinux版本低或者是没安装的原因
yum 安装container-selinux 一般的yum源又找不到这个包
需要安装epel源 才能yum安装container-selinux
然后在安装docker-ce就可以了。
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release #阿里云上的epel源
然后
yum install container-selinux
[root@otc-web ~]# rpm -ivh docker-ce-cli-19.03.9-3.el7.x86_64.rpm
warning: docker-ce-cli-19.03.9-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:docker-ce-cli-1:19.03.9-3.el7 ################################# [100%]
[root@otc-web ~]# rpm -ivh containerd.io-1.2.6-3.3.el7.x86_64.rpm
warning: containerd.io-1.2.6-3.3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:containerd.io-1.2.6-3.3.el7 ################################# [100%]
[root@otc-web ~]# rpm -ivh docker-ce-19.03.9-3.el7.x86_64.rpm
warning: docker-ce-19.03.9-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:docker-ce-3:19.03.9-3.el7 ################################# [100%]
[root@otc-web ~]# docker -v
Docker version 19.03.9, build 9d988398e7
启动docker服务
[root@otc-web harbor]# systemctl start docker
[root@otc-web harbor]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2020-05-29 21:40:36 CST; 5s ago
Docs: https://docs.docker.com
Main PID: 16734 (dockerd)
Tasks: 19
Memory: 53.4M
CGroup: /system.slice/docker.service
└─16734 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
May 29 21:40:35 otc-web dockerd[16734]: time="2020-05-29T21:40:35.910941686+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/...odule=grpc
May 29 21:40:35 otc-web dockerd[16734]: time="2020-05-29T21:40:35.910971108+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
May 29 21:40:35 otc-web dockerd[16734]: time="2020-05-29T21:40:35.929002966+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
May 29 21:40:35 otc-web dockerd[16734]: time="2020-05-29T21:40:35.940863310+08:00" level=info msg="Loading containers: start."
May 29 21:40:36 otc-web dockerd[16734]: time="2020-05-29T21:40:36.120245811+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address ...P address"
May 29 21:40:36 otc-web dockerd[16734]: time="2020-05-29T21:40:36.168317738+08:00" level=info msg="Loading containers: done."
May 29 21:40:36 otc-web dockerd[16734]: time="2020-05-29T21:40:36.243035693+08:00" level=info msg="Docker daemon" commit=9d988398e7 graphdriver(s)=overlay2...on=19.03.9
May 29 21:40:36 otc-web dockerd[16734]: time="2020-05-29T21:40:36.243104524+08:00" level=info msg="Daemon has completed initialization"
May 29 21:40:36 otc-web dockerd[16734]: time="2020-05-29T21:40:36.261347579+08:00" level=info msg="API listen on /var/run/docker.sock"
May 29 21:40:36 otc-web systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
或
2、使用 root
权限登录 Centos。确保 yum 包更新到最新。
$ sudo yum update
3、卸载旧版本(如果安装过旧版本的话)
$ sudo yum remove docker docker-common docker-selinux docker-engine
4、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
5、设置yum源
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
中国大陆,可以改成aliyun镜像仓库
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
6、可以查看所有仓库中所有docker版本,并选择特定版本安装
$ yum list docker-ce --showduplicates | sort -r
7、docker 服务安装
yum install docker-ce-3:20.10.6-3.el7.x86_64
[root@sgpexchangemysql-192-168-8-61 ~]# docker version
Client: Docker Engine - Community
Version: 20.10.6
API version: 1.41
Go version: go1.13.15
Git commit: 370c289
Built: Fri Apr 9 22:45:33 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.6
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 8728dd2
Built: Fri Apr 9 22:43:57 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.4
GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
runc:
Version: 1.0.0-rc93
GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
docker-init:
Version: 0.19.0
GitCommit: de40ad0