How to use docker desktop status command to check Docker Desktop status

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will learn how to check the status of your Docker Desktop installation using the docker info command. We will explore two different output formats: the default human-readable format and the JSON format, which is ideal for scripting and automation.

Through hands-on steps, you will execute the docker info command to retrieve detailed information about your Docker environment, including container and image counts, server version, storage driver, and other system configurations. You will see how the default format provides a quick overview and how the JSON format allows for easier programmatic processing of the Docker status information.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("Docker")) -.-> docker/SystemManagementGroup(["System Management"]) docker/SystemManagementGroup -.-> docker/info("Display System-Wide Information") subgraph Lab Skills docker/info -.-> lab-555149{{"How to use docker desktop status command to check Docker Desktop status"}} end

Check Docker Desktop status using default format

In this step, we will learn how to check the status of the Docker daemon using the docker info command with the default output format. The docker info command provides detailed information about the Docker installation, including the number of containers, images, storage driver, and other system-level information.

First, open the terminal in your LabEx VM environment. You can do this by clicking on the terminal icon in the taskbar or by pressing Ctrl + Alt + T.

Now, execute the following command to display the Docker information in the default format:

docker info

This command will output a lot of information about your Docker environment. Scroll through the output to see details like the Docker version, the number of running and stopped containers, the number of images, the storage driver being used, and various system configurations.

For example, you should see lines similar to these in the output:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 20.10.21
Storage Driver: overlay2
...

This default format is useful for a quick overview of the Docker daemon's status and configuration.

Check Docker Desktop status using json format

In the previous step, we checked the Docker daemon status using the default output format of docker info. While the default format is easy to read for humans, it's not ideal for programmatic processing. In this step, we will learn how to get the Docker information in JSON format, which is much more suitable for scripting and automation.

To get the output in JSON format, we can use the --format flag with the docker info command and specify the format as json.

Execute the following command in your terminal:

docker info --format '{{json .}}'

Let's break down this command:

  • docker info: This is the base command to get Docker system information.
  • --format '{{json .}}': This flag tells Docker to format the output. The value '{{json .}}' uses Go templating syntax. . represents the entire data structure returned by docker info, and {{json .}} formats this structure as a JSON string.

After executing the command, you will see the same information as before, but this time it will be presented as a single, valid JSON object. The output will look something like this (the exact content will vary based on your Docker environment):

{
  "ID": "...",
  "Containers": 0,
  "ContainersRunning": 0,
  "ContainersPaused": 0,
  "ContainersStopped": 0,
  "Images": 0,
  "Driver": "overlay2",
  "SystemStatus": null,
  "Plugins": {
    "Volume": ["local"],
    "Network": ["bridge", "host", "ipvlan", "macvlan", "null", "overlay"],
    "Authorization": null,
    "Log": [
      "awslogs",
      "fluentd",
      "gcplogs",
      "gelf",
      "journald",
      "json-file",
      "local",
      "logentries",
      "splunk",
      "syslog"
    ]
  },
  "MemoryLimit": true,
  "SwapLimit": true,
  "KernelMemory": true,
  "CpuCfsPeriod": true,
  "CpuCfsQuota": true,
  "CpuShares": true,
  "CpuSet": true,
  "PidsLimit": true,
  "OomKillDisable": true,
  "IPv4Forwarding": true,
  "BridgeNfIptables": true,
  "BridgeNfIp6tables": true,
  "Debug": false,
  "NFd": -1,
  "OomScoreAdj": -1,
  "Goroutines": -1,
  "SystemTime": "...",
  "LoggingDriver": "json-file",
  "CgroupDriver": "cgroupfs",
  "CgroupVersion": "1",
  "NEventsListener": -1,
  "KernelVersion": "...",
  "OperatingSystem": "...",
  "OSType": "linux",
  "Architecture": "x86_64",
  "IndexServerAddress": "https://index.docker.io/v1/",
  "RegistryConfig": {
    "AllowNondistributableArtifactsAfterDate": "2020-12-25T00:00:00Z",
    "InsecureRegistryCIDRs": ["127.0.0.0/8"],
    "IndexConfigs": {
      "docker.io": {
        "Name": "docker.io",
        "Mirrors": [],
        "Secure": true,
        "Official": true
      }
    },
    "Mirrors": []
  },
  "NCPU": -1,
  "MemTotal": -1,
  "GenericResources": null,
  "DockerRootDir": "/var/lib/docker",
  "HttpProxy": "",
  "HttpsProxy": "",
  "NoProxy": "",
  "ExperimentalBuild": false,
  "LiveRestoreEnabled": false,
  "Runtimes": { "runc": { "path": "runc" } },
  "DefaultRuntime": "runc",
  "Swarm": {
    "NodeID": "",
    "LocalNodeState": "inactive",
    "ControlAvailable": false,
    "Error": "",
    "RemoteManagers": null
  },
  "ContainerdCommit": { "ID": "...", "Expected": "..." },
  "RuncCommit": { "ID": "...", "Expected": "..." },
  "InitCommit": { "ID": "...", "Expected": "..." },
  "SecurityOptions": ["apparmor", "seccomp"],
  "ProductLicense": "",
  "DefaultAddressPools": null,
  "Warnings": null
}

This JSON output can be easily parsed by scripting languages or other tools, making it very useful for automating tasks related to Docker.

Summary

In this lab, we learned how to check the status of the Docker daemon using the docker info command. We explored two different output formats: the default human-readable format and the JSON format.

We first used docker info to get a quick overview of the Docker environment, including container and image counts, server version, and storage driver. Then, we learned how to use the --format '{{json .}}' flag with docker info to obtain the same information in a structured JSON format, which is more suitable for scripting and automation.