Kubernetes pods can be made up of multiple containers, that’s why containers is an array
A common example would be a worker container or say a webserver and then another one that is used for shipping logs, or if you’re using a service mesh to act as a ‘router’ to encrypt communication to other pods.
Ahh, sorry -
So for arrays in yaml (yaml spec refers to them as collections), the space doesn’t matter because it can tell it’s an element of a collection by looking for a dash then a space “- “.
Because it can clearly parse the elements, the spacing doesn’t matter.
In YAML, the - indicates a list item, and it must be at the same indentation level as the parent key (containers). The list items (name, image, etc.) are indented under -, but the - itself aligns with containers to show they belong to it. So containers is a list, and each - starts a new item in that list.