A bind mount
The one difference between the syntaxes, and the reason to prefer --mount
/srv/data:/var/lib/data
Convert -v to --mount. They do the same job with one behavioural difference, and that difference is why scripted deployments should use the longer form.
Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.
The answer appears here
Paste on the left and press Convert. Nothing leaves this tab.
Nothing else to flag.
No formatting problems, and nothing the rules object to. Worth remembering what that covers: this reads the file you pasted, not the account or cluster it will be applied to.
No finding matches that filter.
Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.
The one difference between the syntaxes, and the reason to prefer --mount
/srv/data:/var/lib/data
An anonymous volume with a random name that nothing will ever refer to
/var/lib/data
Means three different things across run, --mount and Compose
./data:/var/lib/data
These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.
A typo in the host path creates an empty root-owned directory rather than failing, so the container starts against no data and looks healthy.
Instead:Use --mount type=bind. It errors on a missing source, which is what you want from automation.
That is an anonymous volume with a random name. It survives the container, nothing references it, and it is invisible until docker system df shows the size.
Instead:Name it: -v myapp-data:/var/lib/data.
docker run resolves it against your shell's directory, --mount rejects it, and Compose resolves it against the compose file's directory.
Instead:Use absolute paths in anything scripted.
A typo in a bind mount path gives you a new empty directory owned by root, not an error. The container starts, finds nothing, and initialises itself from scratch.
A database container with a mistyped data path mounts a fresh empty directory, sees no data, and initialises a new empty database. Everything comes up healthy. The old data is still on disk at the path you meant, and nothing has said a word. --mount fails to start the container instead, which is the outcome you want.
A path starting with / or . is a bind mount of that host directory. A plain name is a named volume, created if it does not exist. A single path with no colon is an ANONYMOUS volume with a random 64-character name.
They survive the container, nothing refers to them, and they only show up in docker volume ls as a wall of hex. This is where the reclaimable gigabytes in docker system df usually come from. Naming the volume costs nothing and makes it backupable.
docker run -v resolves against your current directory. --mount refuses a relative path outright. Compose resolves against the compose file's directory, not against where you ran the command. So the same string means three things.
tmpfs sizing, some volume driver options, and the clearer readonly spelling. It is also self-documenting, since every part is a key=value rather than a position in a colon-separated string.
Whether the host path exists, or what is in it. It converts the syntax, in your browser, and touches nothing.