1.下载rpm包

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

docker-ce-18.09.9-3.el7.x86_64.rpm
docker-ce-cli-18.09.9-3.el7.x86_64.rpm
containerd.io-1.2.13-3.2.el7.x86_64.rpm



http://mirrors.aliyun.com/

libselinux-2.5-15.el7.x86_64.rpm
libselinux-python-2.5-15.el7.x86_64.rpm
libselinux-utils-2.5-15.el7.x86_64.rpm
libsemanage-2.5-14.el7.x86_64.rpm
libsemanage-python-2.5-14.el7.x86_64.rpm
libsepol-2.5-10.el7.x86_64.rpm
policycoreutils-2.5-34.el7.x86_64.rpm
policycoreutils-python-2.5-34.el7.x86_64.rpm
selinux-policy-3.13.1-266.el7.noarch.rpm
selinux-policy-targeted-3.13.1-266.el7.noarch.rpm
setools-libs-3.3.8-4.el7.x86_64.rpm


https://centos.pkgs.org/

container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm

2.安装

rpm -Uvh libselinux-2.5-15.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh libselinux-python-2.5-15.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh libselinux-utils-2.5-15.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh libsemanage-2.5-14.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh libsemanage-python-2.5-14.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh libsepol-2.5-10.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh policycoreutils-2.5-34.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh policycoreutils-python-2.5-34.el7.x86_64.rpm --nodeps --nosignature
rpm -Uvh selinux-policy-3.13.1-266.el7.noarch.rpm --nodeps --nosignature
rpm -Uvh selinux-policy-targeted-3.13.1-266.el7.noarch.rpm --nodeps --nosignature
rpm -Uvh setools-libs-3.3.8-4.el7.x86_64.rpm --nodeps --nosignature



rpm -Uvh container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm 

rpm -Uvh containerd.io-1.2.13-3.2.el7.x86_64.rpm

rpm -ivh docker-ce-cli-19.03.11-3.el7.x86_64.rpm

3.修改docker.service文件,使用-g参数指定存储位置(可选)

vim /usr/lib/systemd/system/docker.service  

#添加--graph 目录 ,到你想要存放的目录
ExecStart=/usr/bin/dockerd --graph /new-path/docker 

例如:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

3.测试是否安装成功

[root@localhost docker]#systemctl start docker

[root@localhost docker]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 18.09.9
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-514.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.702GiB
 Name: localhost.localdomain
 ID: 3NZF:GJMH:XHTP:SSWE:AR2V:6UCG:SE5W:OZLG:AZGW:ANXQ:FX7O:SS63
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine