<p>I am new to kubernetes/docker and was wondering what the docker volume configuration equivalent is in kubernetes.
In the docker-compose file, you can create volumes like this:</p>

<pre><code>volumes:
   - wordpress/file-abc (1)
   - wordpress:/var/www/html (2)
</code></pre>

<p>(1) tells docker to keep the content within <code>wordpress/file-abc</code> unchanged if there is a change in /var/www/html.
(2) allows changes to all the wordpress files except <code>wordpress/file-abc</code>.</p>

<p>What is the kubernetes equivalent of (1) when creating persistent volumes in kubernetes? Are volumeMounts in Kubernetes the equivalent for (2)?</p>

saragit
<p>In Docker,
Actually, volume is managed by docker using three way,
1.volume
2.Bind mount
3.tmpfs.</p>

<p># volume: when you use -v and --volume in docker without referencing the full or relative path on the host machine then docker will create volume which is new directory and its is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.</p>

<p># Bind mount: when you use -v or --volume with the file or directory  which is referenced by its full or relative path on the host machine then docker will just map the that host machine directory with the mentioned container directory.</p>

<p>#tmpfs:  When you create a container with a tmpfs mount, the container can create files outside the container’s writable layer.for more detail see this <a href="https://docs.docker.com/storage/tmpfs/" rel="noreferrer">document</a>.</p>

<p>In Kubernetes:
Volume is not only restricted to a directory on disk. You can create a different type of volume in different filesystem. you can get the details supported volume <a href="https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes" rel="noreferrer">here</a>. 
You can compare docker bind mount with Kubernetes volume type hostpath.see details <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="noreferrer">here</a>. </p>

<p>The answer of when creating persistent volumes in kubernetes?</p>

<p>when you need to have your data persistent across container, you can create presistant volume using any volume type.</p>

<p>Are volumeMounts in Kubernetes the equivalent for (2)?</p>

<p>NO,volumeMounts is used in kubernetes to  mount a volume that is created by a any volume type.
for example:</p>

<pre><code>volumes:
  - name: test-volume
    # This GCE PD must already exist.
    gcePersistentDisk:
      pdName: my-data-disk
      fsType: ext4
</code></pre>

<p>mount now</p>

<pre><code>    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
</code></pre>
