100 Days of DevOps Day 55 Issue

Create a pod named webserver. Create an emptyDir volume named shared-logs. Create a regular container in the webserver pod from the nginx:latest image named nginx-container, and an init container from the ubuntu:latest image named sidecar-container. Add the following command to the sidecar-container “sh”,“-c”,“while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done” Mount the shared-logs volume in both containers at /var/log/nginx. Ensure all containers are in a running state. I have just been getting: Image used is not ‘ubuntu:latest’ for ‘sidecar-container’,Shared volume is not mounted correctly on the sidecar container,pod ‘webserver’ is not 'Running. How can I fix this problem?

It would have helped if you had shared the manifest you used for this task.

This requires placing the sidecar-container in the initContainers with restartPolicy set to Always.
Something like this:

initContainers:
- name: sidecar-container
  image: ubuntu:latest
  command: [“sh”, “-c”, “while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done”]
  restartPolicy: Always
  volumeMounts:
  - name: shared-logs
    mountPath: /var/log/nginx

Refer to the official docs for more on sidecar containers.

Thank you very much let me try that out

Thank you, it worked