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.