一、查找Docker的软件包
[root@staging ~]# rpm -qa | grep docker
docker-client-1.13.1-203.git0be3e21.el7.centos.x86_64
docker-common-1.13.1-203.git0be3e21.el7.centos.x86_64
docker-1.13.1-203.git0be3e21.el7.centos.x86_64
二、卸载旧版本
[root@staging ~]# yum -y remove docker-client-1.13.1-203.git0be3e21.el7.centos.x86_64
[root@staging ~]# yum -y remove docker-common-1.13.1-203.git0be3e21.el7.centos.x86_64
[root@staging ~]# yum -y remove docker-1.13.1-203.git0be3e21.el7.centos.x86_64
三、安装依赖
[root@staging ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
四、添加Docker镜像源
[root@staging ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@staging ~]# ll /etc/yum.repos.d/
total 12
-rw-r--r--. 1 root root 2523 Aug 6 00:39 CentOS-Base.repo
-rw-r--r-- 1 root root 2640 Mar 16 2020 docker-ce.repo
-rw-r--r--. 1 root root 664 Aug 6 00:40 epel.repo
五、安装Docker
[root@staging ~]# yum -y install docker-ce
六、重新设置Docker Root Dir
#1.查看之前Docker目录位置
[root@staging docker-image]# docker info |grep "Docker Root Dir"
Docker Root Dir: /data3/docker-data/docker
#2.重新设置 Docker Root Dir
[root@staging ~]# vim /usr/lib/systemd/system/docker.service
# 在 ExecStart=/usr/bin/dockerd 后追加 --graph=/data3/docker-data/docker,注意如果本来后面有其他参数不要搞乱了
# 示例如下(后面其他参数是我个人配置别的使用的请忽略)
ExecStart=/usr/bin/dockerd --graph=/data3/docker-data/docker -H fd:// --containerd=/run/containerd/containerd.sock
七、重新加载配置启动服务
#1.重新加载配置启动服务
[root@staging ~]# systemctl daemon-reload
#2.立即启动服务并设置开机自启
[root@staging ~]# systemctl enable --now docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
八、验证Docker服务
[root@staging ~]# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.6.3-docker)
scan: Docker Scan (Docker Inc., v0.9.0)
Server:
Containers: 6
Running: 3
Paused: 0
Stopped: 3
Images: 12
Server Version: 20.10.11
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc version: v1.0.2-0-g52b36a2
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1160.15.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.47GiB
Name: staging
ID: YYU2:DJRP:A2PK:CS2C:MMCJ:FSXI:Y6F5:OQKI:NWWE:6BQB:JZZC:YOD6
Docker Root Dir: /data3/docker-data/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
九、验证镜像
[root@staging ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab/gitlab-ce latest c3747d47072b 9 days ago 2.33GB
sonatype/nexus3 latest 84bed2486e46 3 months ago 655MB
registry.cn-shanghai.aliyuncs.com/linux_yuncloud/jira v8.16.1 959de0407cc8 6 months ago 645MB
registry.cn-shanghai.aliyuncs.com/linux_yuncloud/confluence v7.9.3 97c84f97cdb4 6 months ago 848MB
amancevice/superset latest e5aed97adf10 7 months ago 2.24GB
portainer/portainer latest 580c0e4e98b0 8 months ago 79.1MB
十、重启Docker服务
[root@staging ~]# docker restart $(docker container ls -aq)
3b491ceabf5e
56c25e5d5e99
a6885caddd7e
8dea79eff7eb
fd65270e17d6
ed2bb7849dec
至此Docker版本升级完成!
标签:staging,--,Centos7,版本升级,yum,docker,root,Docker
From: https://www.cnblogs.com/GAO321/p/16723147.html