<p>Is there a way to share the filesystem of two containers in a multi-container pod? <strong>without using shared volumes</strong>?</p>

<p>I have following pod manifest</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: pod 
  name: pod
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pod 
  template:
    metadata:
      labels:
        app: pod 
    spec:
      containers:
      - image: nginx:latest
        name: nginx
      - image: jenkins 
        name: jenkins
</code></pre>

<p>I want to access /var/jenkins_home path which is available in jenkins container from nginx container.</p>

<p>This is just for experimental purposes, I am trying to learn ways to share filesystem/things in general across containers in a pod.</p>

smc
<p>You can't share files between containers without some sort of shared volume.</p>

<p>Part of the goal of a containerized system is that the container filesystems are isolated from each other.  There are a huge number of practical problems with sharing files specifically (what if the containers are on different nodes? what if you have three replicas each of Jenkins and Nginx? what if they're all trying to write the same files?) and in general it's better to just avoid sharing files altogether if that's a possibility.</p>

<p>In the specific example you've shown, the lifecycle of a Jenkins CI system and an Nginx server will just be fundamentally different; whenever Jenkins builds something you don't want to restart it to also restart the Web server, and you could very easily want to scale up the Web tier without adding Jenkins workers.  A better approach here would be to have Jenkins generate custom Docker images, push them to a registry, and then use the Kubernetes API to create a separate Nginx Deployment.</p>

<p>In most cases (especially because of the scaling considerations) you should avoid multi-container pods altogether.</p>

<p>(A more specific example of a case where this setup <em>does</em> make sense is if you're storing credentials somewhere like a Hashicorp Vault server.  You would need an init container to connect to Vault, retrieve the credentials, and deposit them in an <code>emptyDir</code> volume, and then the main container can start up having gotten those credentials.  As far as the main server container is concerned it's the only important part of this pod, and logically the pod is nothing more than the server container with some auxiliary stuff.)</p>
