<p>I am trying to start a deployment but I am getting this error</p>
<pre><code>error: error validating &quot;httpd-basic-deployment.yaml&quot;: error validating data: ValidationError(Deployment.spec.template.spec.containers): invalid type for io.k8s.api.core.v1.PodSpec.containers: got &quot;map&quot;, expected &quot;array&quot;; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>
<p>of the below pod definition file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ebay-app
spec:
  selector:
    matchLabels:
        environment: dev
        app: ebay
  replicas: 1
  template:
    metadata:
      labels:
        environment: dev
        app: ebay
    spec:

      volumes:
        - name: volume
          hostPath:
            path: /mnt/data

      containers:
        name: container1-nginx
        image: nginx
        volumeMounts:
           name: volume
           mountPath: /var/nginx-data

        name: container2-tomcat
        image: tomcat
      nodeSelector:
        boardType: x86vm
</code></pre>
<p>I tried listing the cotnainers again:</p>
<pre><code> volumes:
    - name: volume
      hostPath:
        path: /mnt/data

  containers:
    - name: container1-nginx
      image: nginx
      volumeMounts:
         name: volume
         mountPath: /var/nginx-data
    
    - name: container2-tomcat
      image: tomcat

  nodeSelector:
    boardType: x86vm
</code></pre>
<p>that results in different error</p>
<pre><code>error: error validating &quot;httpd-basic-deployment.yaml&quot;: error validating data: ValidationError(Deployment.spec.template.spec.containers[0].volumeMounts): invalid type for io.k8s.api.core.v1.Container.volumeMounts: got &quot;map&quot;, expected &quot;array&quot;; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>
<p>what am i doing wrong ?</p>

Ciasto piekarz
<p>VolumeMounts should also have <code>-</code>. It indicates start of an array. Change it as shown below.</p>
<pre><code>volumeMounts:
- name: volume
  mountPath: /var/nginx-data
</code></pre>
<p>Have a look at <a href="https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/" rel="noreferrer">this example yaml</a> to create pod that has two containers and shares same volume. In this example, its clear where to use <code>-</code> symbol and where not.</p>
