Running Docker on a VPS: the practical starting point
Docker turned self-hosting from a weekend project into a single command. But running it well on a VPS takes a few deliberate choices, or you end up fighting it months later.
**Keep data in volumes, not containers.** A container is disposable; the data you care about should live in a named volume or a bound host directory. If you rebuild a container and lose your data, the data was in the wrong place.
**Set resource limits.** Without limits, one runaway container can consume all the RAM and take down everything else on the box. Set memory and CPU limits on your containers so a misbehaving app is contained.
**Terminate TLS in one place.** Run a single reverse proxy — Nginx or a proxy container — that owns ports 80 and 443 and routes to the containers behind it. Every app then gets HTTPS without each one handling certificates separately.
**Pin your image versions.** Using the "latest" tag seems convenient until an update breaks your app at 2am. Pin to a specific version, and update deliberately.
**Know where your logs go.** Container logs grow. Configure rotation so a chatty container does not fill the disk and wedge the server.
**Back up the volumes and the compose files.** Your compose file plus the data volumes together are the whole application. Version-control the compose files and back up the volumes with the same discipline as any other data.
Get these five right — volumes, limits, one proxy, pinned versions, log rotation — and Docker becomes a reliable way to run a whole stack of self-hosted apps on modest hardware.