github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/docs/reference/commandline/version.md (about)

     1  ---
     2  title: "version"
     3  description: "The version command description and usage"
     4  keywords: "version, architecture, api"
     5  ---
     6  
     7  # version
     8  
     9  ```markdown
    10  Usage:  docker version [OPTIONS]
    11  
    12  Show the Docker version information
    13  
    14  Options:
    15    -f, --format string       Format the output using the given Go template
    16        --help                Print usage
    17        --kubeconfig string   Kubernetes config file
    18  ```
    19  
    20  ## Description
    21  
    22  The version command prints the current version number for all independently
    23  versioned Docker components. Use the [`--format`](#format) option to customize
    24  the output.
    25  
    26  The version command (`docker version`) outputs the version numbers of Docker
    27  components, while the `--version` flag (`docker --version`) outputs the version
    28  number of the Docker CLI you are using.
    29  
    30  ### Default output
    31  
    32  The default output renders all version information divided into two sections;
    33  the "Client" section contains information about the Docker CLI and client
    34  components, and the "Server" section contains information about the Docker
    35  Engine and components used by the Engine, such as the "Containerd" and "Runc"
    36  OCI Runtimes.
    37  
    38  The information shown may differ depending on how you installed Docker and
    39  what components are in use. The following example shows the output on a macOS
    40  machine running Docker Desktop:
    41  
    42  ```console
    43  $ docker version
    44  
    45  Client:
    46   Version:           20.10.16
    47   API version:       1.41
    48   Go version:        go1.17.10
    49   Git commit:        aa7e414
    50   Built:             Thu May 12 09:17:28 2022
    51   OS/Arch:           darwin/amd64
    52   Context:           default
    53  
    54  Server: Docker Desktop 4.8.2 (77141)
    55   Engine:
    56    Version:          20.10.16
    57    API version:      1.41 (minimum version 1.12)
    58    Go version:       go1.17.10
    59    Git commit:       f756502
    60    Built:            Thu May 12 09:15:33 2022
    61    OS/Arch:          linux/amd64
    62    Experimental:     false
    63   containerd:
    64    Version:          1.6.4
    65    GitCommit:        212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
    66   runc:
    67    Version:          1.1.1
    68    GitCommit:        v1.1.1-0-g52de29d
    69   docker-init:
    70    Version:          0.19.0
    71    GitCommit:        de40ad0
    72  ```
    73  
    74  ### Client and server versions
    75  
    76  Docker uses a client/server architecture, which allows you to use the Docker CLI
    77  on your local machine to control a Docker Engine running on a remote machine,
    78  which can be (for example) a machine running in the Cloud or inside a Virtual Machine.
    79  
    80  The following example switches the Docker CLI to use a [context](context.md)
    81  named "remote-test-server", which runs an older version of the Docker Engine
    82  on a Linux server:
    83  
    84  ```console
    85  $ docker context use remote-test-server
    86  remote-test-server
    87  
    88  $ docker version
    89  
    90  Client:
    91   Version:           20.10.16
    92   API version:       1.40 (downgraded from 1.41)
    93   Go version:        go1.17.10
    94   Git commit:        aa7e414
    95   Built:             Thu May 12 09:17:28 2022
    96   OS/Arch:           darwin/amd64
    97   Context:           remote-test-server
    98  
    99  Server: Docker Engine - Community
   100   Engine:
   101    Version:          19.03.8
   102    API version:      1.40 (minimum version 1.12)
   103    Go version:       go1.12.17
   104    Git commit:       afacb8b
   105    Built:            Wed Mar 11 01:29:16 2020
   106    OS/Arch:          linux/amd64
   107   containerd:
   108    Version:          v1.2.13
   109    GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
   110   runc:
   111    Version:          1.0.0-rc10
   112    GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
   113   docker-init:
   114    Version:          0.18.0
   115    GitCommit:        fec3683
   116  ```
   117  
   118  ## Examples
   119  
   120  ### <a name="format"></a> Format the output (--format)
   121  
   122  The formatting option (`--format`) pretty-prints the output using a Go template,
   123  which allows you to customize the output format, or to obtain specific information
   124  from the output. Refer to the [format command and log output](https://docs.docker.com/config/formatting/)
   125  page for details of the format.
   126  
   127  ### Get the server version
   128  
   129  ```console
   130  $ docker version --format '{{.Server.Version}}'
   131  
   132  20.10.16
   133  ```
   134  
   135  ### Dump raw JSON data
   136  
   137  ```console
   138  $ docker version --format '{{json .}}'
   139  
   140  {"Client":{"Platform":{"Name":"Docker Engine - Community"},"Version":"19.03.8","ApiVersion":"1.40","DefaultAPIVersion":"1.40","GitCommit":"afacb8b","GoVersion":"go1.12.17","Os":"darwin","Arch":"amd64","BuildTime":"Wed Mar 11 01:21:11 2020","Experimental":true},"Server":{"Platform":{"Name":"Docker Engine - Community"},"Components":[{"Name":"Engine","Version":"19.03.8","Details":{"ApiVersion":"1.40","Arch":"amd64","BuildTime":"Wed Mar 11 01:29:16 2020","Experimental":"true","GitCommit":"afacb8b","GoVersion":"go1.12.17","KernelVersion":"4.19.76-linuxkit","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"v1.2.13","Details":{"GitCommit":"7ad184331fa3e55e52b890ea95e65ba581ae3429"}},{"Name":"runc","Version":"1.0.0-rc10","Details":{"GitCommit":"dc9208a3303feef5b3839f4323d9beb36df0a9dd"}},{"Name":"docker-init","Version":"0.18.0","Details":{"GitCommit":"fec3683"}}],"Version":"19.03.8","ApiVersion":"1.40","MinAPIVersion":"1.12","GitCommit":"afacb8b","GoVersion":"go1.12.17","Os":"linux","Arch":"amd64","KernelVersion":"4.19.76-linuxkit","Experimental":true,"BuildTime":"2020-03-11T01:29:16.000000000+00:00"}}
   141  ```
   142  
   143  ### Print the current context
   144  
   145  The following example prints the currently used [`docker context`](context.md):
   146  
   147  ```console
   148  $ docker version --format='{{.Client.Context}}'
   149  default
   150  ```
   151  
   152  As an example, this output can be used to dynamically change your shell prompt
   153  to indicate your active context. The example below illustrates how this output
   154  could be used when using Bash as your shell.
   155  
   156  Declare a function to obtain the current context in your `~/.bashrc`, and set
   157  this command as your `PROMPT_COMMAND`
   158  
   159  ```console
   160  function docker_context_prompt() {
   161          PS1="context: $(docker version --format='{{.Client.Context}}')> "
   162  }
   163  
   164  PROMPT_COMMAND=docker_context_prompt
   165  ```
   166  
   167  After reloading the `~/.bashrc`, the prompt now shows the currently selected
   168  `docker context`:
   169  
   170  ```console
   171  $ source ~/.bashrc
   172  context: default> docker context create --docker host=unix:///var/run/docker.sock my-context
   173  my-context
   174  Successfully created context "my-context"
   175  context: default> docker context use my-context
   176  my-context
   177  Current context is now "my-context"
   178  context: my-context> docker context use default
   179  default
   180  Current context is now "default"
   181  context: default>
   182  ```
   183  
   184  Refer to the [`docker context` section](context.md) in the command line reference
   185  for more information about `docker context`.