aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/plugins/docker.py43
1 files changed, 28 insertions, 15 deletions
diff --git a/sos/plugins/docker.py b/sos/plugins/docker.py
index 3cce15ed..d8c854f9 100644
--- a/sos/plugins/docker.py
+++ b/sos/plugins/docker.py
@@ -72,21 +72,34 @@ class Docker(Plugin):
if self.get_option('all'):
ps_cmd = "%s -a" % ps_cmd
- img_cmd = 'docker images -q'
- insp = set()
-
- for icmd in [ps_cmd, img_cmd]:
- result = self.get_command_output(icmd)
- if result['status'] == 0:
- for con in result['output'].splitlines():
- insp.add(con)
-
- insp = list(insp)
- if insp:
- for container in insp:
- self.add_cmd_output("docker inspect %s" % container)
- if self.get_option('logs'):
- self.add_cmd_output("docker logs -t %s" % container)
+ fmt = '{{lower .Repository}}:{{lower .Tag}} {{lower .ID}}'
+ img_cmd = "docker images --format='%s'" % fmt
+ vol_cmd = 'docker volume ls -q'
+
+ containers = self._get_docker_list(ps_cmd)
+ images = self._get_docker_list(img_cmd)
+ volumes = self._get_docker_list(vol_cmd)
+
+ for container in containers:
+ self.add_cmd_output("docker inspect %s" % container)
+ if self.get_option('logs'):
+ self.add_cmd_output("docker logs -t %s" % container)
+
+ for img in images:
+ name, img_id = img.strip().split()
+ insp = name if 'none' not in name else img_id
+ self.add_cmd_output("docker inspect %s" % insp)
+
+ for vol in volumes:
+ self.add_cmd_output("docker volume inspect %s" % vol)
+
+ def _get_docker_list(self, cmd):
+ ret = []
+ result = self.get_command_output(cmd)
+ if result['status'] == 0:
+ for ent in result['output'].splitlines():
+ ret.append(ent)
+ return ret
def postproc(self):
# Attempts to match key=value pairs inside container inspect output