<p>I have a PHP container, I am getting my media from an S3 bucket but resizing them locally and then the container uses them from local. I don't care about persistence or about sharing between containers, but there is a fair amount of I/O. Do I need an emptydir volume or am I ok just creating the files inside the container... basically I'm asking does a volume do anything apart from adding persistence and shareability.</p>

Wayne Theisinger
<p>Generally, working inside a container filesystem will be slower than a localhost volume, as inside a container you have to deal with overlay filesystem overhead.</p>
<blockquote>
<p>Use volumes for write-heavy workloads: Volumes provide the best and
most predictable performance for write-heavy workloads. This is
because they bypass the storage driver and do not incur any of the
potential overheads introduced by thin provisioning and copy-on-write.
Volumes have other benefits, such as allowing you to share data among
containers and persisting your data even if no running container is
using them.<br />
<a href="https://docs.docker.com/storage/storagedriver/overlayfs-driver/#performance-best-practices" rel="nofollow noreferrer">https://docs.docker.com/storage/storagedriver/overlayfs-driver/#performance-best-practices</a>.</p>
</blockquote>
<p>In practice, of course, it may depend a) on your workloads, b) on what exactly storage backs your volume (is it actually a local disk or, say, some network drive? how fast is it?).</p>
<p>Also note that overlay file systems may lack support for some file operations.<br />
Say, <code>overlay2</code> does not actually support renaming directories.<br />
<a href="https://docs.docker.com/storage/storagedriver/overlayfs-driver/#modifying-files-or-directories" rel="nofollow noreferrer">https://docs.docker.com/storage/storagedriver/overlayfs-driver/#modifying-files-or-directories</a>.</p>
<p>So, general advice would be to stick with some kind of local volume.</p>
