Comparison
Docker named volumes or bind mounts for an edge IoT stack
Short answer
Put application-owned state on named Docker volumes: the InfluxDB database, Grafana's dashboards and users, the Node-RED flow files. Bind-mount only the configuration you deliberately edit or version on the host, read-only where the service tolerates it. The decision turns on ownership, recoverability and portability, not speed or security, because both mount types perform only as well as the storage behind them.

On this page
Keep the split you already have, and make it deliberate. In a Node-RED, MQTT, InfluxDB 2 and Grafana stack on an edge box, put application-owned state — the InfluxDB database, Grafana's dashboards and users, the Node-RED flow files — on named Docker volumes, and bind-mount only the configuration you deliberately edit or version on the host, read-only where the service tolerates it. The decision turns on ownership, recoverability and portability, not speed or security: both mount types write to the same class of backing storage and perform only as well as the device behind them. Below is the comparison, the per-service decision, and the test that proves the layout holds.
What each mount type actually does #
A named volume is storage whose backing location Docker creates and manages. You never choose the directory; you address the volume by name through the Docker CLI or API, and the Docker documentation calls volumes easier to back up or migrate than bind mounts. The container writes into it exactly as if it were a local directory.
A bind mount takes a file or directory on the host and mounts it from the host into the container. You own the path, the permissions and the contents, and you can edit them with your usual host tools while the container is running.
Whichever you pick, the Docker documentation generally prefers the storage flag --mount over -v, because it is more explicit and supports options the short form cannot express. Use the long form in your Compose file for the same reason: someone reading the service definition six months from now should not have to remember the short form's path-versus-name ambiguity.
The comparison that decides it #
| Criterion | Named volume | Bind mount |
|---|---|---|
| Who owns the location | Docker creates and manages it; the application owns the contents | You select and manage the host file or directory |
| Editing on the host | Awkward; not intended for routine manual edits | Direct, with host editors and file tools |
| Portability | The declaration survives a move to a host with a different directory layout | The deployment depends on specific host paths and their permissions |
| First start | A new, empty volume is normally populated from the image's contents at that path | The container sees only what the host path holds; an empty directory hides the image's files |
| Backup and migration | Easier to back up or migrate, per the Docker documentation | Fits existing host backup jobs, but live database files still need consistency control |
| Exposure | No arbitrary host directory is handed to the container, though Docker administration reaches it | The chosen host path is exposed to the container with the access mode you set |
| Speed | Set by the backing storage, filesystem and workload | Set by the backing storage, filesystem and workload |
Read the last two rows together: a named volume is not a security boundary against anyone who can administer Docker, and neither type is faster. If your reason for choosing is "volumes are safer" or "bind mounts are quicker," that reason is wrong and the real decision is ownership.
The decision for each container #
InfluxDB 2: named volume, always explicitly named. The database files are application-owned state that no human edits in place. Point the mount at the data location the image documents, keep the same volume identity across container replacements, and change it only as a planned migration.
Grafana: named volume for its state. Grafana's Docker documentation supports volumes or bind mounts for persistence; take the named volume for the internal database that holds dashboards, users and data-source definitions. If you deliver dashboards as provisioning files, those files — not the database — are the bind-mount candidate, read-only.
Node-RED: named volume, unless the flows live in version control. The flow files are saved from the browser-based editor, so they behave like state; but if you deploy reviewed flow files from a repository, bind-mount that directory instead and accept that editor saves need a redeployment path. Where Node-RED runs under a controller's own app system, the platform supplies the persistence instead, as the guide to configuring flows and dashboards for Node-RED on ctrlX OS shows.
MQTT broker: persistent storage only if the broker keeps state. A broker relaying sensor data with no configured persistence needs nothing; one holding retained messages or persistent sessions for offline clients does. Check the broker's own persistence setting before giving it a volume.
The same split applies to other gateway containers you add later: Ignition Docker modes bind the config directory, not nested resource mounts, which is the config-as-bind-mount rule applied to a SCADA platform.
First-start behavior that catches people out #
Mounting anything over a container path hides whatever the image placed at that path. Bind-mount an empty host directory over a service's configuration directory and the container sees an empty directory — the stock files are gone from its view, and it either fails to start or starts on defaults. A new, empty named volume behaves the opposite way: Docker normally copies the image's contents at that path into the volume before the container starts. Inspect the actual mounted contents after first start instead of assuming the two initializations are interchangeable.
A worked capacity check #
The mount decision does not size the storage, but it decides which filesystem you must measure. Worked example with illustrative inputs: an InfluxDB 2 named volume holds 1.8 GB on day one and 2.6 GB on day eight, so it grows 0.8 GB over 7 days, about 0.114 GB per day. For a 90-day retention policy that is 0.114 × 90 ≈ 10.3 GB of data. Add equal headroom for the write-ahead log, index and compaction: budget about 21 GB. Now find which filesystem holds Docker's storage area on your edge box. If the volume shares a 32 GB card with the OS and images, this workload does not fit and either the retention or the device changes; if the backing store shows 100 GB free, the layout stands as-is.
Prove the layout before you trust it #
A mount declaration is a claim until a recreation test confirms it. Run this sequence at commissioning:
- Record every running container's mounts: type, source, destination and access mode, and confirm they match the Compose file you think is deployed.
- Write a known test point into InfluxDB and note its tag, value and timestamp.
- Stop and recreate the containers — the same operation a routine image update performs.
- Query the test point back. If it is missing, the data location was not inside the mount; start from the troubleshooting path for a Node-RED InfluxDB Grafana stack that shows no data and fix the mount before collecting real data.
- Take an application-consistent backup with each service's own tools and restore it in isolation once. A backup that has never been restored is a hope, not a recovery point.
Step 4 is the whole test: everything else in this article exists so that step passes.
When to break the rule #
Two legitimate exceptions. First, a bind-only layout — every persistent path under one host directory — is reasonable on a single-box learning rig or where an existing host backup job already covers that directory tree; you trade portability for one familiar place to look. Second, a volume-only layout suits stacks deployed purely as code, where configuration ships inside the image or as environment variables and no human edits files on the host at all. What is not an exception is mixing the two by accident: an InfluxDB data directory bind-mounted because a tutorial said so, plus an anonymous Grafana volume nobody named, is how stacks lose history during a routine update.
Questions asked
Do named volumes survive stopping and recreating the whole stack?
Yes. A named volume persists through container recreation and stack shutdown, and only an explicit volume-removal operation deletes it. The trap is anonymous volumes: a container that declares storage without a name gets a fresh, hard-to-track volume each time it is recreated, so the data appears to vanish while it sits on an orphan. Name every volume the stack depends on.
Can I move an existing InfluxDB database from a bind mount to a named volume?
Treat it as a migration, not a remount. Stop ingestion so no writes land mid-copy, use the database's own backup and restore tools to move the data into the new volume, then query a known tag, value and timestamp before deleting the old directory. Copying live database files at the filesystem level without quiescing writes risks a restored database that fails its own consistency checks.
Where does Docker keep named volumes on the host?
Inside Docker's own storage area, not in a directory you choose. Do not reach into that area by hand to edit or copy files; manage volumes through the Docker CLI or API and take backups with the application's own tools. If direct host access to the files matters to your workflow, that requirement is itself the argument for a bind mount.
What happens if I bind-mount an empty directory over a config path?
The container sees your empty directory and the image's own files at that path disappear from its view, so the service usually fails to start or falls back to defaults. Either copy the stock file out of the image first and edit that copy, or use a named volume, which Docker normally populates from the image's content when the volume is new and empty.


