<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bind Mount on StackOnward</title><link>https://stackonward.com/tags/bind-mount/</link><description>Recent content in Bind Mount on StackOnward</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 11 Sep 2026 05:18:00 +0800</lastBuildDate><atom:link href="https://stackonward.com/tags/bind-mount/index.xml" rel="self" type="application/rss+xml"/><item><title>How to Configure Docker Volume Permissions and Secrets</title><link>https://stackonward.com/posts/docker-volume-permissions-secrets/</link><pubDate>Fri, 11 Sep 2026 05:12:00 +0800</pubDate><guid>https://stackonward.com/posts/docker-volume-permissions-secrets/</guid><description>&lt;p&gt;How to configure Docker volume permissions starts with a numeric UID and GID match, not a matching username. Put database files and other container-generated state on a named volume, bind-mount host-managed config read-only, and grant each secret only to the service that reads it as a file. Recreate the container to prove the mount. Restore a backup in a separate environment to prove the backup.&lt;/p&gt;
&lt;figure&gt;
 &lt;img src="https://stackonward.com/images/posts/docker-volume-permissions-secrets/en/storage-boundaries.svg" alt="An application container writes database state to a named volume, reads host config read-only, and reads a password from a granted secret file" loading="lazy" decoding="async"&gt;
 &lt;figcaption&gt;Named volumes hold writable state. Bind mounts hold host-managed config. Secret files are granted per service.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id="choose-a-named-volume-bind-mount-or-tmpfs"&gt;Choose a named volume, bind mount, or tmpfs&lt;/h2&gt;
&lt;div class="table-responsive" role="region" aria-label="Scrollable table" tabindex="0"&gt;
 &lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Type&lt;/th&gt;
					&lt;th&gt;What belongs there&lt;/th&gt;
					&lt;th&gt;Why&lt;/th&gt;
					&lt;th&gt;Main risk&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Named volume&lt;/td&gt;
					&lt;td&gt;Databases, queues, application state&lt;/td&gt;
					&lt;td&gt;Docker manages the lifecycle; the path is not tied to one host layout&lt;/td&gt;
					&lt;td&gt;Host backup and migration must name the volume and its driver&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Bind mount&lt;/td&gt;
					&lt;td&gt;Caddyfile, explicit data directories, host scripts&lt;/td&gt;
					&lt;td&gt;The path is visible to existing backup and permission tools&lt;/td&gt;
					&lt;td&gt;The host path, owner, and SELinux or AppArmor labels all have to match&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;tmpfs&lt;/td&gt;
					&lt;td&gt;Short-lived sensitive files or fast scratch data that must not persist&lt;/td&gt;
					&lt;td&gt;Nothing is written to durable disk&lt;/td&gt;
					&lt;td&gt;A restart drops the files; the size counts against container memory&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://docs.docker.com/engine/storage/" target="_blank" rel="noopener"&gt;Docker storage&lt;span class="sr-only"&gt;(opens in a new tab)&lt;/span&gt;&lt;/a&gt; treats &lt;a href="https://docs.docker.com/engine/storage/volumes/" target="_blank" rel="noopener"&gt;volumes&lt;span class="sr-only"&gt;(opens in a new tab)&lt;/span&gt;&lt;/a&gt; as the default for data a container generates. &lt;a href="https://docs.docker.com/engine/storage/bind-mounts/" target="_blank" rel="noopener"&gt;Bind mounts&lt;span class="sr-only"&gt;(opens in a new tab)&lt;/span&gt;&lt;/a&gt; are for files the host already owns. &lt;a href="https://docs.docker.com/engine/storage/tmpfs/" target="_blank" rel="noopener"&gt;tmpfs&lt;span class="sr-only"&gt;(opens in a new tab)&lt;/span&gt;&lt;/a&gt; stays in host memory and is gone when the container stops. The image writable layer is the wrong place for runtime data: deleting the container deletes that layer.&lt;/p&gt;</description></item></channel></rss>