Hi All. i was going through an example in kubernetes docs <https://kubernetes.io . . .

Sundeep Y:
Hi All. i was going through an example in kubernetes docs
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/
here it says “the second container writes the index.html file in the root directory of the nginx server” but the second container mount path is

/pod-data

and 1st containers mount path is

/usr/share/nginx/html

How does this make any sense. can anyone clarify me on this ?

jeromeza:
The mount path is the path INSIDE the container - this can be different. for each container - it doesn’t matter

The volume is what matters - it exposes the storage on the host (or elsewhere) to the container (and the container mount it at any location it wishes aka the mount point)

jeromeza:
So container 1 could have /pod-data and container 2 could have /usr/share/nginx - at the end of the day, the data will be written to the volume that lives outside of the container (and if you ls that volume you’d see files from both containers).

I hope that makes sense.

jeromeza:
Think of volume mount paths as link → to the real volume

jeromeza:
Additionally - it’s 100% correct, the root directory of nginx in a container is /usr/share/nginx/html

“By default, Nginx looks in the /usr/share/nginx/html directory inside of the container for files to serve.”

https://www.docker.com/blog/how-to-use-the-official-nginx-docker-image/

unnivkn:
As you can see both containers are part of a same pod, and the same volumes are shared among them, you will be able to access the files on a c1 mount point to a c2 mount point.

unnivkn:

unnivkn:

Sundeep Y:
ya i got all that. but it says:

Recall that the debian Container created the index.html file in the nginx root directory. Use curl to send a GET request to the nginx server:

[email protected]:/# curl localhost

debian container didnt create index.html in nginx root directory instead it created in

echo Hello from the debian container &gt; /pod-data/index.html

so when curl localhost was done how did it connect to index.html , was my question

unnivkn:
since both containers are on the same pod and it shares same network namespace

Sundeep Y:
got it, even though the root of one container is different from the other, since they both share the same volume , the root folder reference changes in both the containers