'Nginx index.html is override With Shared Volume
I have a Pod with an emptyDir volume mounted in two containers:
- nginx at /usr/share/nginx/html/
- busybox at /var/html/
If i create a file with html extension inside busybox container at /var/html this file is copied to nginx container in /usr/share/nginx/html and i cant figure out why this happens.
The same behavior happens in this documentation example: https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/
Pod Manifest:
apiVersion: v1
kind: Pod
metadata:
name: web-server
labels:
book: kubernetes-in-action
section: 6-2-1-Using-an-emptyDir-volume
spec:
containers:
- image: nginx
name: web-server
volumeMounts:
- name: html-vol
mountPath: /usr/share/nginx/html
- image: busybox
name: content-agent
command: ["/bin/sh", "-c"]
args: ["\
echo \"$(date) | creating html file at var/html\"; \
echo \"<h1> $(date) </h1>\" > var/html/front.html; \
sleep 15; \
while true; do \
echo \"$(date) | append to html file at var/html\"; \
echo \"<h1> $(date) </h1>\" >> var/html/front.html; \
sleep 15; \
done; \
"]
volumeMounts:
- name: html-vol
mountPath: /var/html
volumes:
- name: html-vol
emptyDir: {}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|