title: List container images in Kubernetes cluster with SIZE (like docker image ls)
body: <p>In the Kubernetes documentation <a href="https://kubernetes.io/docs/tasks/access-application-cluster/list-all-running-container-images/#list-all-container-images-in-all-namespaces" rel="noreferrer">List All Container Images Running in a Cluster</a> we can list all containers by:</p>
  
  <pre><code>kubectl get pods --all-namespaces -o jsonpath="{..image}" |\
  tr -s '[[:space:]]' '\n' |\
  sort |\
  uniq -c
  </code></pre>
  
  <p>Here is an example of output:</p>
  
  <pre><code>  1 cdkbot/addon-resizer-amd64:1.8.1
    1 cdkbot/hostpath-provisioner-amd64:1.0.0
    1 cdkbot/registry-amd64:2.6
    1 coredns/coredns:1.6.6
    1 docker.io/cdkbot/addon-resizer-amd64:1.8.1
    1 docker.io/cdkbot/hostpath-provisioner-amd64:1.0.0
    1 docker.io/cdkbot/registry-amd64:2.6
    1 docker.io/coredns/coredns:1.6.6
    1 docker.io/grafana/grafana:6.4.3
    2 docker.io/istio/citadel:1.5.1
    2 docker.io/istio/examples-bookinfo-details-v1:1.15.0
    2 docker.io/istio/examples-bookinfo-productpage-v1:1.15.0
    2 docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
    2 docker.io/istio/examples-bookinfo-reviews-v1:1.15.0
    2 docker.io/istio/examples-bookinfo-reviews-v2:1.15.0
    2 docker.io/istio/examples-bookinfo-reviews-v3:1.15.0
    2 docker.io/istio/galley:1.5.1
    4 docker.io/istio/kubectl:1.5.1
    4 docker.io/istio/mixer:1.5.1
    2 docker.io/istio/pilot:1.5.1
   34 docker.io/istio/proxyv2:1.5.1
    2 docker.io/istio/sidecar_injector:1.5.1
    2 docker.io/jaegertracing/all-in-one:1.16
    1 docker.io/kubernetesui/dashboard:v2.0.0
    1 docker.io/kubernetesui/metrics-scraper:v1.0.4
    2 docker.io/library/nginx:latest
    2 docker.io/prom/prometheus:v2.12.0
    1 docker.io/radial/busyboxplus:curl
    1 grafana/grafana:6.4.3
    2 k8s.gcr.io/metrics-server-amd64:v0.2.1
    1 kubernetesui/dashboard:v2.0.0
    1 kubernetesui/metrics-scraper:v1.0.4
    2 nginx
    2 quay.io/kiali/kiali:v1.9
    1 radial/busyboxplus:curl
  </code></pre>
  
  <p>Unfortunately the size of the docker image is missing. Is there a way to get the container image size? Pretty much like <code>docker image ls</code>. Copy of the output from this <a href="http://www.askdevops.org/63/docker-list-all-images-local-docker-image-ls-example" rel="noreferrer">example</a> for convenience:</p>
  
  <pre><code>$ docker image ls
  REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
  docker.io/ubuntu            latest              3556258649b2        7 days ago          64.2 MB
  docker.io/alpine            latest              b7b28af77ffe        2 weeks ago         5.58 MB
  docker.io/centos            latest              9f38484d220f        4 months ago        202 MB
  docker.io/hello-world       latest              fce289e99eb9        7 months ago        1.84 kB
  </code></pre>