<p>The following kubectl expression returns the image version:</p>
<p><code>kubectl get po nginx -o jsonpath='{.spec.containers[].image}{&quot;\n&quot;}'</code></p>
<p>But what does the '[]' signify exactly? i get that it is saying image is a child of containers which is a child of spec but why the <em>empty</em> square bracket?</p>

2bon2b
<p><code>{.spec.containers}</code> will return an array. Using empty square bracket means the <strong>desired value is an array.</strong></p>
<p>you can validate this by running the following, the output of the query is an array:</p>
<pre><code> kubectl get po mongo  -o jsonpath='{.spec.containers}{&quot;\n&quot;}'
[{&quot;image&quot;:&quot;mongo&quot;,&quot;imagePullPolicy&quot;:&quot;Always&quot;,&quot;name&quot;:&quot;mongo&quot;,&quot;ports&quot;:[{&quot;containerPort&quot;:27107,&quot;protocol&quot;:&quot;TCP&quot;}],&quot;resources&quot;:{},&quot;terminationMessagePath&quot;:&quot;/dev/termination-log&quot;,&quot;terminationMessagePolicy&quot;:&quot;File&quot;,&quot;volumeMounts&quot;:[{&quot;mountPath&quot;:&quot;/var/run/secrets/kubernetes.io/serviceaccount&quot;,&quot;name&quot;:&quot;default-token-c949d&quot;,&quot;readOnly&quot;:true}]},{&quot;image&quot;:&quot;nginx&quot;,&quot;imagePullPolicy&quot;:&quot;Always&quot;,&quot;name&quot;:&quot;nginx&quot;,&quot;ports&quot;:[{&quot;containerPort&quot;:80,&quot;protocol&quot;:&quot;TCP&quot;}],&quot;resources&quot;:{},&quot;terminationMessagePath&quot;:&quot;/dev/termination-log&quot;,&quot;terminationMessagePolicy&quot;:&quot;File&quot;,&quot;volumeMounts&quot;:[{&quot;mountPath&quot;:&quot;/var/run/secrets/kubernetes.io/serviceaccount&quot;,&quot;name&quot;:&quot;default-token-c949d&quot;,&quot;readOnly&quot;:true}]}]
</code></pre>
<p>when used with <code>[]</code>, we expect the output of <code>.spec.containers</code> to be array and process it already :</p>
<pre><code>kubectl get po mongo  -o jsonpath='{.spec.containers[]}{&quot;\n&quot;}'
{&quot;image&quot;:&quot;mongo&quot;,&quot;imagePullPolicy&quot;:&quot;Always&quot;,&quot;name&quot;:&quot;mongo&quot;,&quot;ports&quot;:[{&quot;containerPort&quot;:27107,&quot;protocol&quot;:&quot;TCP&quot;}],&quot;resources&quot;:{},&quot;terminationMessagePath&quot;:&quot;/dev/termination-log&quot;,&quot;terminationMessagePolicy&quot;:&quot;File&quot;,&quot;volumeMounts&quot;:[{&quot;mountPath&quot;:&quot;/var/run/secrets/kubernetes.io/serviceaccount&quot;,&quot;name&quot;:&quot;default-token-c949d&quot;,&quot;readOnly&quot;:true}]}
</code></pre>
