A VPS that runs several Compose stacks needs one decision made once: where the files live.
Start with the standard directories
Linux separates service data from vendor software.
/srvholds data that the machine serves./optholds third-party bundles installed outside the package manager.
> A long-running Compose stack is service data, so /srv is its home.
Keep the stack together
The Filesystem Hierarchy Standard would put configuration in /etc and data under /srv. Compose works against that split. It resolves relative bind-mount paths from the directory that holds the compose file, so separating configuration from data forces an absolute path into every volume line.
One directory per stack keeps it organised:
/srv/
app-one/
docker-compose.yml
.env
data/
media/
app-two/
docker-compose.yml
.env
data/
Then cd /srv/app-one && docker compose up -d works, a backup takes one path, and Ansible manages one tree per stack instead of three.
Practical rules
- Give every stack its own directory under
/srv, named after the service. - Keep
.envbeside the compose file and set its permissions to 600. - Bind-mount data into subdirectories of the stack, so a move copies everything in one step.
- Run each stack as its own user, with ownership of its directory and nothing else.
- Back up the whole stack directory, compose file included, and restore it the same way.
The standard exists to keep a system predictable. The stack directory exists to keep a deployment operable. On a Compose host, operability wins.
