<p>In K8s i'm practising the example <em>6.1. A pod with two containers sharing the same volume: fortune-pod.yaml</em> from the book <strong>kubernetes in Action</strong>. In volumes concept where my pod contain 2 containers, one of the containers is not running, Please guide me where i'm doing wrong. to run the pod successfully.
on checking the logs of the container i'm getting the below error:</p>
<pre><code>Defaulted container &quot;fortune-cont&quot; out of: fortune-cont, web-server 
</code></pre>
<p>But where as in pod description events it looks like this.</p>
<pre><code>Events:
  Type     Reason     Age                  From               Message
  ----     ------     ----                 ----               -------
  Normal   Scheduled  40m                  default-scheduler  Successfully assigned book/vol-1-fd556f5dc-8ggj6 to minikube
  Normal   Pulled     40m                  kubelet            Container image &quot;nginx:alpine&quot; already present on machine
  Normal   Created    40m                  kubelet            Created container web-server
  Normal   Started    40m                  kubelet            Started container web-server
  Normal   Created    39m (x4 over 40m)    kubelet            Created container fortune-cont
  Normal   Started    39m (x4 over 40m)    kubelet            Started container fortune-cont
  Normal   Pulled     38m (x5 over 40m)    kubelet            Container image &quot;xxxx/fortune:v1&quot; already present on machine
  Warning  BackOff    25s (x188 over 40m)  kubelet            Back-off restarting failed container
</code></pre>
<p>here is my deployment file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: vol-1
  namespace: book
spec:
  replicas: 1
  selector:
    matchLabels:
      name: fortune-vol-1
      type: volume
  template:
    metadata:
      labels:
        name: fortune-vol-1
        type: volume
    spec:
      containers:
      - image: ****/fortune:v1
        name: fortune-cont
        volumeMounts:
        - name: html 
          mountPath: /var/htdocs
      - image: nginx:alpine
        name: web-server
        volumeMounts:
        - name: html
          mountPath: /usr/share/nginx/html
          readOnly: true
        ports:
        - containerPort: 80
          protocol: TCP
      volumes:
        - name: html
          emptyDir: {}
</code></pre>
<p>Here is my pod description for containers.</p>
<pre><code>Containers:
  fortune-cont:
    Container ID:   docker://3959e47a761b670ee826b2824efed09d8f5d6dfd6451c4c9840eebff018a3586
    Image:          prav33n/fortune:v1
    Image ID:       docker-pullable://prav33n/fortune@sha256:671257f6387a1ef81a293f8aef27ad7217e4281e30b777a7124b1f6017a330f8
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 24 Nov 2022 02:05:26 +0530
      Finished:     Thu, 24 Nov 2022 02:05:26 +0530
    Ready:          False
    Restart Count:  17
    Environment:    &lt;none&gt;
    Mounts:
      /var/htdocs from html (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-spdq4 (ro)
  web-server:
    Container ID:   docker://37d831a2f7e97abadb548a21ecb20b5c784b5b3d6102cf8f939f2c13cdfd08c0
    Image:          nginx:alpine
    Image ID:       docker-pullable://nginx@sha256:455c39afebd4d98ef26dd70284aa86e6810b0485af5f4f222b19b89758cabf1e
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Thu, 24 Nov 2022 01:02:55 +0530
    Ready:          True
    Restart Count:  0
    Environment:    &lt;none&gt;
    Mounts:
      /usr/share/nginx/html from html (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-spdq4 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  html:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  &lt;unset&gt;
  kube-api-access-spdq4:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason   Age                    From     Message
  ----     ------   ----                   ----     -------
  Warning  BackOff  4m20s (x281 over 64m)  kubelet  Back-off restarting failed container
</code></pre>

<p>Your <em>Pod</em> named <code>vol-1</code> has two <em>containers</em>:</p>
<ul>
<li>One named <code>fortune-cont</code></li>
<li>One named <code>web-server</code></li>
</ul>
<p>If you run <code>kubectl logs vol-1</code>, Kubernetes doesn't know which container you're asking about, so it has to pick one, and tells you:</p>
<blockquote>
<p>Defaulted container &quot;fortune-cont&quot; out of: fortune-cont, web-server</p>
</blockquote>
<p>You can select a container explicitly with the <code>-c</code> option:</p>
<pre><code>kubectl logs vol-1 -c web-server
</code></pre>
