升级docker至最新版本

升级docker至最新版本

1.查找主机上关于Docker的软件包

[root@pre1 ~]# rpm -qa | grep docker

docker-1.13.1-88.git07f3374.el7.centos.x86_64

docker-common-1.13.1-88.git07f3374.el7.centos.x86_64

docker-client-1.13.1-88.git07f3374.el7.centos.x86_64

  

2.使用yum remove卸载软件

[root@pre1 ~]# yum remove -y docker-1.13.1-88.git07f3374.el7.centos.x86_64

[root@pre1 ~]# yum remove –y docker-common-1.13.1-88.git07f3374.el7.centos.x86_64

[root@pre1 ~]# yum remove -y docker-client-1.13.1-88.git07f3374.el7.centos.x86_64

在使用docker命令会提示docker不存在

[root@pre1 ~]# docker version

-bash: /usr/bin/docker: No such file or directory

  

3.使用curl升级到最新版

[root@pre1 ~]# curl -fsSL https://get.docker.com/ | sh

# Executing docker install script, commit: 2f4ae48

+ sh -c 'yum install -y -q yum-utils'

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

+ sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'

…

Metadata Cache Created

+ '[' -n '' ']'

+ sh -c 'yum install -y -q docker-ce'

warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.6-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY

Public key for docker-ce-18.09.6-3.el7.x86_64.rpm is not installed

Importing GPG key 0x621E9F35:

 Userid     : "Docker Release (CE rpm) <docker@docker.com>"

 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35

 From       : https://download.docker.com/linux/centos/gpg

If you would like to use Docker as a non-root user, you should now consider

adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user 

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

  

4.查看一下安装的版本

[root@pre1 ~]# docker version

Client:

 Version:           18.09.6

 API version:       1.39

 Go version:        go1.10.8

 Git commit:        481bc77156

 Built:             Sat May  4 02:34:58 2019

 OS/Arch:           linux/amd64

 Experimental:      false

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  

5.启动docker

[root@pre1 ~]# systemctl start docker.service

  

6.加入开机自启动

[root@pre1 ~]# systemctl enable docker

Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

  

7.查看Docker系统信息

[root@pre1 ~]# docker info

Containers: 1

 Running: 0

 Paused: 0

 Stopped: 1

Images: 1

Server Version: 18.09.6

Storage Driver: overlay2

 Backing Filesystem: xfs

 Supports d_type: false

 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: bb71b10fd8f58240ca47fbb579b9d1028eea7c84

runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30

init version: fec3683

Security Options:

 seccomp

  Profile: default

Kernel Version: 3.10.0-327.el7.x86_64

Operating System: CentOS Linux 7 (Core)

OSType: linux

Architecture: x86_64

CPUs: 2

Total Memory: 7.523GiB

Name: pre1

ID: U5QL:5TI3:SWE7:FR2U:WYOG:D6RX:HHQI:TED3:FT2S:QDW2:VOLL:Z5OT

Docker Root Dir: /var/lib/docker

Debug Mode (client): false

Debug Mode (server): 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

  

原文地址:https://www.cnblogs.com/heyongboke/p/10832024.html