human readable docker ps output

docker ps | sed -e 's/ /\+/g' -e 's/CONTAINER ID/CONTAINER_ID/' | tr -s '+' '\t' | q -t 'select c1,substr(c7, 0, 40),c2,c6 from -' | column -t
When you run a lot of containers the built in docker ps output becomes unreadable. This command formats the output to be easier on the eyes. Requires q (https://github.com/harelba/q) text as data.
Sample Output
CONTAINER_ID  NAMES                                    IMAGE                                      PORTS
ad9d74b9a1bd  akaivola/ndb:datanode                    ndb_datanode2_1
be9c3a7c2c4b  akaivola/ndb:datanode                    ndb_datanode1_1
983c6eada93c  ndb_sqlnode1_1                           akaivola/ndb:sql                           0.0.0.0:49233->3306/tcp,  0.0.0.0:49234->8500/tcp
16de1f8a672c  ndb_sqlnode2_1                           akaivola/ndb:sql                           0.0.0.0:49231->3306/tcp,  0.0.0.0:49232->8500/tcp
7c6b790739f6  ndb_datanode1_1/management_1,ndb_datano  akaivola/ndb:management                    0.0.0.0:49230->1186/tcp
d1136b0ba95c  ndb_datanode1_1/etcd_1,ndb_datanode1_1/  coreos/etcd:latest                         7001/tcp,                 0.0.0.0:49229->4001/tcp
88349c3c1f9a  akaivola/databaseinitializer:latest      databaseinitializer
f1bd06c6950c  dnsmasq                                  pmenglund/dnsmasq:latest                   172.17.42.1:53->53/udp,   53/tcp
53fd22d0b727  consul                                   192.168.50.50:5000/akaivola/consul:latest  0.0.0.0:8301->8301/tcp,   0.0.0.0:8302->8302/tcp,  0.0.0.0:8400->8400/tcp,  0.0.0.0:8500->8500/tcp,  0.0.0.0:8600->8600/udp
fcc385af7c63  jenkinsmysql                             akaivola/jenkins-mysql:latest              0.0.0.0:3306->3306/tcp

0
By: akaivola
2014-06-06 07:20:36

What Others Think

I get "-bash: q: command not found" on OSX. What OS is this for? What is q? some kind of sql engine?
proxy · 296 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: