How to use docker desktop version command to check plugin version

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will learn how to use the docker version command to check the version of the Docker Desktop CLI plugin. You will start by executing the basic command to see the default output, which provides detailed version information for various Docker components.

Following that, you will explore how to format the output of the docker version command as JSON, which is useful for scripting and automation. Finally, you will learn how to filter the output to show only the short version number, demonstrating how to extract specific information from the command's output.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("Docker")) -.-> docker/SystemManagementGroup(["System Management"]) docker/SystemManagementGroup -.-> docker/version("Show Docker Version") subgraph Lab Skills docker/version -.-> lab-555152{{"How to use docker desktop version command to check plugin version"}} end

Check Docker Desktop CLI plugin version

In this step, you will learn how to check the version of the Docker Desktop CLI plugin. This is a fundamental operation to understand the environment you are working with.

First, let's use the docker version command. This command displays version information for Docker and its components.

docker version

You should see output similar to this, showing various components and their versions:

Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        f362210
 Built:             Tue Dec 13 08:14:44 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       305620d
  Built:            Tue Dec 13 08:13:56 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.10
  GitCommit:        b34a5c8cd550b1d5803ceac35179cc101f7da787
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The output provides detailed information about both the Docker client and the Docker server (engine). The Version field under Client indicates the version of the Docker CLI you are using.

Format the output as JSON

In the previous step, you saw the default output of the docker version command. This output is human-readable but not ideal for programmatic processing. Docker commands often support formatting the output in different ways, including JSON.

To format the output of docker version as JSON, you can use the --format flag with the value json.

docker version --format json

After executing this command, the output will be a JSON object containing the same version information. It will look something like this:

{
  "Client": {
    "Version": "20.10.21",
    "ApiVersion": "1.41",
    "GoVersion": "go1.16.15",
    "GitCommit": "f362210",
    "Built": "Tue Dec 13 08:14:44 2022",
    "Os": "linux",
    "Arch": "amd64",
    "Context": "default",
    "Experimental": true
  },
  "Server": {
    "Engine": {
      "Version": "20.10.21",
      "ApiVersion": "1.41",
      "MinimumApiVersion": "1.12",
      "GoVersion": "go1.16.15",
      "GitCommit": "305620d",
      "Built": "Tue Dec 13 08:13:56 2022",
      "Os": "linux",
      "Arch": "amd64",
      "Experimental": false
    },
    "Containerd": {
      "Version": "1.6.10",
      "GitCommit": "b34a5c8cd550b1d5803ceac35179cc101f7da787"
    },
    "Runc": {
      "Version": "1.1.4",
      "GitCommit": "v1.1.4-0-g5fd4c4d"
    },
    "DockerInit": {
      "Version": "0.19.0",
      "GitCommit": "de40ad0"
    }
  }
}

This JSON output is structured data that can be easily parsed by other tools or scripts, making it useful for automation and integration.

Show only the short version number

In the previous steps, you learned how to get the full Docker version information and format it as JSON. Sometimes, you only need the short version number for scripting or quick checks.

To get just the short version number of the Docker client, you can use the --version flag.

docker --version

This command will output only the version string, like this:

Docker version 20.10.21, build f362210

This output is concise and directly provides the version information without the additional details shown by docker version. This is particularly useful when you need to quickly check the installed Docker version in a script or on the command line.

Summary

In this lab, you learned how to check the version of the Docker Desktop CLI plugin using the docker version command. This command provides detailed information about the Docker client and server components, including their versions. You also explored how to format the output of the docker version command as JSON using the --format json flag, which is useful for programmatic processing.