Commandes Linux : jq

JQ

Installé avec le paquet jq

 

Afficher la version de la commande jq

jq --version

ou

apt-cache policy jq

 

Pretty-printer la sortie de la commande inspect de Docker

docker container inspect [-f '["Chaine de texte"] {{json .Path.To.Information}}'] container | jq
docker image inspect [-f '["Chaine de texte"] {{json .Path.To.Information}}'] image | jq
docker volume inspect volume | jq
docker network inspect network | jq

ex :

$ docker container inspect --format '{{ json .State }}' hardcore_heisenberg
{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":11579,"ExitCode":0,"Error":"","StartedAt":"2018-10-11T15:15:04.684322824Z","FinishedAt":"0001-01-01T00:00:00Z"}
$ docker container inspect --format '{{ json .State }}' hardcore_heisenberg | jq
{
  "Status": "running",
  "Running": true,
  "Paused": false,
  "Restarting": false,
  "OOMKilled": false,
  "Dead": false,
  "Pid": 11579,
  "ExitCode": 0,
  "Error": "",
  "StartedAt": "2018-10-11T15:15:04.684322824Z",
  "FinishedAt": "0001-01-01T00:00:00Z"
}

Equivaut, sans la couleur à :

$ docker container inspect --format '{{ json .State }}' hardcore_heisenberg | python -m json.tool
{
  "Status": "running",
  "Running": true,
  "Paused": false,
  "Restarting": false,
  "OOMKilled": false,
  "Dead": false,
  "Pid": 11579,
  "ExitCode": 0,
  "Error": "",
  "StartedAt": "2018-10-11T15:15:04.684322824Z",
  "FinishedAt": "0001-01-01T00:00:00Z"
}

 

Fermer le menu
%d blogueurs aiment cette page :