Skip to content

Instantly share code, notes, and snippets.

@KyleBanks
Created February 10, 2017 01:27
Show Gist options
  • Save KyleBanks/8befbf0ae0d0535fa27d33cb67b40bd1 to your computer and use it in GitHub Desktop.
Save KyleBanks/8befbf0ae0d0535fa27d33cb67b40bd1 to your computer and use it in GitHub Desktop.
Returns Docker stats as a JSON Object
docker stats --no-stream \
--format "{\"container\": \"{{ .Container }}\", \"memory\": { \"raw\": \"{{ .MemUsage }}\", \"percent\": \"{{ .MemPerc }}\"}, \"cpu\": \"{{ .CPUPerc }}\"}"
@KyleBanks
Copy link
Author

KyleBanks commented Feb 10, 2017

Sample output:

{  
   "container": "7e9d088ecca3",
   "memory": {  
      "raw": "239.4 MiB / 7.787 GiB",
      "percent": "3.00%"
   },
   "cpu": "100.08%"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment