1.查询当前docker版本及包信息
[root@docker ~]# docker version Client: Version: 1.13.1 API version: 1.26 Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 Go version: go1.10.3 Git commit: b2f74b2/1.13.1 Built: Wed May 1 14:55:20 2019 OS/Arch: linux/amd64 Server: Version: 1.13.1 API version: 1.26 (minimum version 1.12) Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 Go version: go1.10.3 Git commit: b2f74b2/1.13.1 Built: Wed May 1 14:55:20 2019 OS/Arch: linux/amd64 Experimental: false [root@docker ~]# rpm -qa | grep docker docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64
2.卸载掉旧版本
[root@docker ~]# yum remove docker Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package docker.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================================================= Removing: docker x86_64 2:1.13.1-96.gitb2f74b2.el7.centos @extras 65 M Transaction Summary ================================================================================================================================================================================= Remove 1 Package Installed size: 65 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 1/1 warning: /etc/sysconfig/docker-storage saved as /etc/sysconfig/docker-storage.rpmsave Verifying : 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 1/1 Removed: docker.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos Complete! [root@docker ~]# rpm -e docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64 [root@docker ~]# rpm -e docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 [root@docker ~]# rpm -qa | grep docker
3.使用docker提供的脚本安装最新版本
[root@docker ~]# curl -fsSL https://get.docker.com/ | sh
# Executing docker install script, commit: 2f4ae48
+ sh -c 'yum install -y -q yum-utils'
Warning: RPMDB altered outside of yum.
+ sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.uhost.hk
* extras: centos.uhost.hk
* updates: centos.uhost.hk
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 3.4 kB 00:00:00
kubernetes | 1.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/14): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00
(2/14): docker-ce-stable/x86_64/primary_db | 28 kB 00:00:00
(3/14): extras/7/x86_64/filelists_db | 243 kB 00:00:00
(4/14): docker-ce-stable/x86_64/filelists_db | 14 kB 00:00:00
(5/14): docker-ce-stable/x86_64/other_db | 111 kB 00:00:00
(6/14): extras/7/x86_64/prestodelta | 62 kB 00:00:00
(7/14): extras/7/x86_64/other_db | 126 kB 00:00:00
(8/14): kubernetes/filelists | 17 kB 00:00:02
(9/14): kubernetes/other | 32 kB 00:00:02
(10/14): updates/7/x86_64/other_db | 588 kB 00:00:01
(11/14): updates/7/x86_64/prestodelta | 681 kB 00:00:01
(12/14): base/7/x86_64/other_db | 2.6 MB 00:00:06
(13/14): updates/7/x86_64/filelists_db | 3.7 MB 00:00:06
(14/14): base/7/x86_64/filelists_db | 7.1 MB 00:00:11
kubernetes 351/351
kubernetes 351/351
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.启动docker及设置开机自启
[root@docker ~]# systemctl start docker [root@docker ~]# systemctl enable docker
5.查看docker及包信息
[root@docker ~]# rpm -qa | grep docker docker-ce-cli-18.09.6-3.el7.x86_64 docker-ce-18.09.6-3.el7.x86_64 [root@docker ~]# 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 Server: Docker Engine - Community Engine: Version: 18.09.6 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 481bc77 Built: Sat May 4 02:02:43 2019 OS/Arch: linux/amd64 Experimental: false [root@docker ~]# docker info Containers: 22 Running: 0 Paused: 0 Stopped: 22 Images: 23 Server Version: 18.09.6 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: false Native Overlay Diff: true 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-957.12.1.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 1.777GiB Name: docker ID: LKYE:VOPA:ACLB:HZG2:O2Q5:BHD3:UMGG:LKI3:2QBV:JIT4:MGPC:JU6R Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false HTTP Proxy: http://127.0.0.1:8118 HTTPS Proxy: http://127.0.0.1:8118 No Proxy: localhost,172.16.0.0/16,127.0.0.1,10.244.0.0/16 Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled WARNING: overlay2: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will not be supported in future releases.
转载请注明:MitNick » 如何安装最新版本的docker?