Docker 常用命令 – docker version

概要

1、版本信息

Ubuntu 18.04.5
Docker 19.03.6

命令解释

1、命令描述

docker version 用于显示 docker 的版本信息,包括 docker client 和 docker server。

2、用法

docker version [OPTIONS]

docker version 是固定命令关键字,[OPTIONS] 表示是该命令有可选参数。默认情况下,docker version 会返回类 yaml 文件格式的所有版本信息。

如果传递了格式化参数(–format)和参数值,那么该命令会按照传递的 –format 参数的值进行渲染,可见示例部分。

3、可选参数 [OPTIONS]

速记参数名
完整参数名
参数值类型
默认值
参数描述
-f
string
用给定的 Go 模板来格式化输出
string
kubernetes 配置文件

用法示例

1、docker version

jiangzl@ubuntu:/usr/bin$ docker version
Client:
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        369ce74a3c
 Built:             Fri Feb 28 23:45:43 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.6
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       369ce74a3c
  Built:            Wed Feb 19 01:06:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.3-0ubuntu1~18.04.2
  GitCommit:        
 runc:
  Version:          spec: 1.0.1-dev
  GitCommit:        
 docker-init:
  Version:          0.18.0
  GitCommit:

默认输出全部的 docker 版本信息,默认包括客户端与本地服务端两个部分,如果本地服务端服务未启动,则会如下显示:

jiangzl@ubuntu:/usr/bin$ docker version
Client:
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        369ce74a3c
 Built:             Fri Feb 28 23:45:43 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

2、docker version -f ‘{{.Server.Version}}’

jiangzl@ubuntu:/usr/bin$ docker version -f '{{.Server.Version}}'
19.03.6

根据给定的 Go 模板,只输出 docker server 的版本信息。

3、docker version –format='{{.Server.Version}}’

jiangzl@ubuntu:/usr/bin$ docker version --format='{{.Server.Version}}'
19.03.6

根据给定的 Go 模板,只输出 docker server 的版本信息,与上面的命令不同之处只在于参数写法不同。

4、docker version –format ‘{{json .}}’

jiangzl@ubuntu:/usr/bin$ docker version --format '{{json .}}'
{"Client":{"Platform":{"Name":""},"Version":"19.03.6","ApiVersion":"1.40","DefaultAPIVersion":"1.40","GitCommit":"369ce74a3c","GoVersion":"go1.12.17","Os":"linux","Arch":"amd64","BuildTime":"Fri Feb 28 23:45:43 2020","Experimental":false},"Server":{"Platform":{"Name":""},"Components":[{"Name":"Engine","Version":"19.03.6","Details":{"ApiVersion":"1.40","Arch":"amd64","BuildTime":"Wed Feb 19 01:06:16 2020","Experimental":"false","GitCommit":"369ce74a3c","GoVersion":"go1.12.17","KernelVersion":"5.4.0-42-generic","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"1.3.3-0ubuntu1~18.04.2","Details":{"GitCommit":""}},{"Name":"runc","Version":"spec: 1.0.1-dev","Details":{"GitCommit":""}},{"Name":"docker-init","Version":"0.18.0","Details":{"GitCommit":""}}],"Version":"19.03.6","ApiVersion":"1.40","MinAPIVersion":"1.12","GitCommit":"369ce74a3c","GoVersion":"go1.12.17","Os":"linux","Arch":"amd64","KernelVersion":"5.4.0-42-generic","BuildTime":"2020-02-19T01:06:16.000000000+00:00"}}

附录

1、参考

docker version 官方文档:

https://docs.docker.com/engine/reference/commandline/version/

Go 模板官方文档:

http://golang.org/pkg/text/template/

2、docker version –help

jiangzl@ubuntu:/usr/bin$ docker version --help
Usage:  docker version [OPTIONS]
Show the Docker version information
Options:
  -f, --format string       Format the output using the given Go template
      --kubeconfig string   Kubernetes config file

你可能感兴趣的:(docker,linux,java,ubuntu,shell)