back to listing index

How to get docker ps data in JSON format | TimJRobinson

[web search]
Original source (timjrobinson.com)
Tags: json docker
Clipped on: 2017-03-10

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.

 
Image (Asset 1/2) alt=

Be the first to comment.

    Recent Posts

     
    Subscribe!
    Casper WP by Lacy Morrow