title: How to mimic '--volumes-from' in Kubernetes
body: <p>I'm looking for a pattern that allows to share volumes between two containers running on the same pod in Kubernetes.</p>
  
  <p>My use case is:
  I have a Ruby on Rails application running inside a docker container.
  The docker image contains static assets in <code>/app/&lt;app-name&gt;/public</code> directory, and I need to access those assets from the nginx container running alongside in the same pod.</p>
  
  <p>In 'vanilla' docker I would have used <code>--volumes-from</code> flag to share this directory:</p>
  
  <pre><code>docker run --name app -v /app/&lt;app-dir&gt;/public &lt;app-image&gt;
  docker run --volumes-from app nginx
  </code></pre>
  
  <p>After reading this doc: <a href="https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/volumes.md" rel="noreferrer">https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/volumes.md</a>
  I tried this (only relevant entries presented):</p>
  
  <pre><code>spec:
    containers:
      - image: &lt;app-image&gt;
        name: &lt;app-name&gt;
        volumeMounts:
          - mountPath: /app/&lt;app-name&gt;/public
            name: assets
      - image: nginx
        name: nginx
        volumeMounts:
          - mountPath: /var/www/html
            name: assets
            readOnly: true
      volumes:
        - name: assets
          hostPath:
            path: /tmp/assets
  </code></pre>
  
  <p>But:</p>
  
  <ul>
  <li>Even though <code>/tmp/assets</code> on the node exists, it's empty</li>
  <li><code>/app/&lt;app-name&gt;/public</code> inside the app container is also empty</li>
  </ul>
  
  <p>As a workaround I'm gonna try to populate the shared directory when the application container is up (simply <code>cp /app/&lt;app-name&gt;/public/*</code> to shared directory), but I really dislike this idea.</p>
  
  <p><strong>Question:</strong> how to mimic <code>--volumes-from</code> in Kubernetes, or if there is no direct counterpart, how can I share files from one container to other running in the same pod ?</p>
  
  <p><code>apiVersion: v1beta3</code></p>
  
  <pre><code>Client Version: version.Info{Major:"0", Minor:"17", GitVersion:"v0.17.0", GitCommit:"82f8bdac06ddfacf493a9ed0fedc85f5ea62ebd5", GitTreeState:"clean"}
  Server Version: version.Info{Major:"0", Minor:"17", GitVersion:"v0.17.0", GitCommit:"82f8bdac06ddfacf493a9ed0fedc85f5ea62ebd5", GitTreeState:"clean"}
  </code></pre>