docker1.12发布之后时隔好久才迎来2016年docker第二个最重要的版本的发布. 在这篇文章之中我们将一起看一下有哪些特性的增强并来简单体验一下.

主要变更

docker 1.13修复了很多过去的bug,同时也添加了很多新的特性,列举一些主要变化,如下:

项番

详细信息

No.1

plugin相关功能不再是试验功能,正式发布

No.2

增加了docker system相关辅助功能

No.3

增加了docker secret相关辅助功能

No.4

增加了清除无用网络/Volume等相关的prune辅助功能

No.5

docker build时添加步数提示信息

No.6

docker build中添加–network参数支持

No.7

添加了支持VMware Photon OS的RPM

No.8

添加了–shutdown-timeout或者–stop-timeout为停止提供超时设定

No.9

增强了swarm mode的安全管理以及很多功能的强化比如docker node ps添加-a选项,docker service create添加–dns等

No.10

……

影响

基于本次更新主要以功能增强和bug修正为主,所以对之前版本的影响不是很大。
比如弃用的仅仅为docker daemon命令弃用或者docker pull的repo:shortid语法弃用这样影响较小的部分。
另外plugin功能的正式发布会带来一点影响。如果你在docker1.12中使用了plugin相关的试验性功能,你需要先行删除你的那些plugin以及/var/lib/docker/plugins/下的json文件,等docker版本更新之后再重新安装。试验性的功能还是有一些变化的风险性的。

安装前提

假定为centos7.2为宿主OS,之前如果安装有低版本的docker,最好先行删除,同时container-selinux和docker-common也一并删除。
另外linux内核需要在3.10以上,OS应该为64位。

[root@liumiaocn ~]# uname -r
3.10.0-327.el7.x86_64
[root@liumiaocn ~]# getconf LONG_BIT
64
[root@liumiaocn ~]#

安装

安装yum-utils

[root@liumiaocn ~]# yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.btte.net
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Package yum-utils-1.1.31-40.el7.noarch already installed and latest version
Nothing to do
[root@liumiaocn ~]# 
已经安装

设定yum-config-manager

[root@liumiaocn ~]# yum-config-manager \
>     --add-repo \
>     https://docs.docker.com/engine/installation/linux/repo_files/centos/docker.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://docs.docker.com/engine/installation/linux/repo_files/centos/docker.repo
grabbing file https://docs.docker.com/engine/installation/linux/repo_files/centos/docker.repo to /etc/yum.repos.d/docker.repo
repo saved to /etc/yum.repos.d/docker.repo
[root@liumiaocn ~]#

更新yum的package索引

[root@liumiaocn ~]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
base                                                                                                                        | 3.6 kB  00:00:00
docker-main                                                                                                                 | 2.9 kB  00:00:00
epel/x86_64/metalink                                                                                                        | 4.6 kB  00:00:00
extras                                                                                                                      | 3.4 kB  00:00:00
updates                                                                                                                     | 3.4 kB  00:00:00
docker-main/primary_db                                                                                                      |  28 kB  00:00:02
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Metadata Cache Created
[root@liumiaocn ~]#

安装docker-engine

[root@liumiaocn ~]# rpm -e docker-common-1.10.3-59.el7.centos.x86_64
[root@liumiaocn ~]#
[root@liumiaocn ~]#
[root@liumiaocn ~]# yum -y docker-engine
Loaded plugins: fastestmirror, langpacks
No such command: docker-engine. Please use /usr/bin/yum --help
[root@liumiaocn ~]# yum -y install docker-engine
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.13.0-1.el7.centos will be installed
--> Processing Dependency: docker-engine-selinux >= 1.13.0-1.el7.centos for package: docker-engine-1.13.0-1.el7.centos.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-engine-1.13.0-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-engine-selinux.noarch 0:1.13.0-1.el7.centos will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================
 Package                                  Arch                      Version                                   Repository                      Size
===================================================================================================================================================
Installing:
 docker-engine                            x86_64                    1.13.0-1.el7.centos                       docker-main                     19 M
Installing for dependencies:
 docker-engine-selinux                    noarch                    1.13.0-1.el7.centos                       docker-main                     28 k
 libtool-ltdl                             x86_64                    2.4.2-21.el7_2                            base                            49 k

Transaction Summary
===================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total size: 19 M
Installed size: 65 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : docker-engine-selinux-1.13.0-1.el7.centos.noarch                                                                                1/3
  Installing : libtool-ltdl-2.4.2-21.el7_2.x86_64                                                                                              2/3
  Installing : docker-engine-1.13.0-1.el7.centos.x86_64                                                                                        3/3
  Verifying  : libtool-ltdl-2.4.2-21.el7_2.x86_64                                                                                              1/3
  Verifying  : docker-engine-selinux-1.13.0-1.el7.centos.noarch                                                                                2/3
  Verifying  : docker-engine-1.13.0-1.el7.centos.x86_64                                                                                        3/3

Installed:
  docker-engine.x86_64 0:1.13.0-1.el7.centos

Dependency Installed:
  docker-engine-selinux.noarch 0:1.13.0-1.el7.centos                              libtool-ltdl.x86_64 0:2.4.2-21.el7_2

Complete!
[root@liumiaocn ~]#

启动docker

[root@liumiaocn ~]# systemctl enable docker; systemctl start docker;
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@liumiaocn ~]#

确认版本

[root@liumiaocn ~]# docker version
Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:55:28 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:55:28 2017
 OS/Arch:      linux/amd64
 Experimental: false
[root@liumiaocn ~]#

新增功能

docker新添加的特性的使用方法,比如docker system:

[root@liumiaocn ~]# docker system

Usage:  docker system COMMAND

Manage Docker

Options:
      --help   Print usage

Commands:
  df          Show docker disk usage
  events      Get real time events from the server
  info        Display system-wide information
  prune       Remove unused data

Run 'docker system COMMAND --help' for more information on a command.
[root@liumiaocn ~]#

docker secret:

[root@liumiaocn ~]# docker secret

Usage:  docker secret COMMAND

Manage Docker secrets

Options:
      --help   Print usage

Commands:
  create      Create a secret from a file or STDIN as content
  inspect     Display detailed information on one or more secrets
  ls          List secrets
  rm          Remove one or more secrets

Run 'docker secret COMMAND --help' for more information on a command.
[root@liumiaocn ~]#

总结

这篇文章中一起看了一下docker1.13中有哪些新的特性以及如何在centos上进行安装。详细的使用在后面的文章中将会进一步展开。