Jay Taylor's notes
back to listing indexHow to get docker ps data in JSON format | TimJRobinson
[web search]If you want to get the output of docker ps
in JSON format the easiest way is to run the remote docker API and use that, you can read about how to do that here
However if you can’t run the remote API because of security issues or for other reasons there is another way! With curl version 7.40 (If this isn’t available on your distro click here) and newer you can get data from the local unix socket, and docker always runs the remote api on docker.sock.
Here’s what you have to run:
curl --unix-socket /var/run/docker.sock http:/containers/json
Tada! Nice JSON Formatted docker ps output. I recommend using the jq library if you want an easy way to parse it in bash.
Also on TimJRobinson
-
Ubuntu logstash default install directory
- 5 comments •
- 3 years ago•
Kadir Korkmaz — Teşekkürler :)
-
Daily coding lessons
- 12 comments •
- 3 years ago•
Joe Zimmerman — You realize you essentially just recreated the models from Backbone, right? Except you don't have events and you use a …
-
How to mock and unit test moment.js
- 4 comments •
- 3 years ago•
garukun — This doesn't really talk about how to mock out moment calls. It basically wraps moment around with another function.
-
How to uninstall / delete OSX mail app
- 1 comment •
- 2 years ago•
poorpaddy — I get operation not permitted when I trymv /Applications/Mail.app /dump