apiVersion: v1
# Which kind of object are we defining?
kind: Pod

metadata:
  name: two-containers-pod

spec:
  restartPolicy: Never
  # This pod will mount a volume
  volumes:
  - name: shared-data
    emptyDir: {}
  # This pod consists of 2 containers and both will
  # mount this pod's volume called shared-data
  containers:
  # Container n.1: a plain Nginx server running as a container
  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html
  # Container n.2: a one-shot container that will run a shell script and die.
  - name: writer-container
    image: alpine
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/ash"]
    # This container writew the index.html file served by nginx.
    args: ["-c", "date > /pod-data/index.html"]
