Containers make it easy to run many services side by side, each with its own dependencies, on one server. They also make it easy to fill a server's memory, leak logs onto the disk and expose services by accident. This guide covers the practices that keep a container host healthy, building on our Docker deployment guide.
Why the Platform Fits Containers
- KVM virtualisation: your VPS has its own kernel, so Docker, Podman, cgroups v2 and overlay filesystems work as on a physical machine.
- Multiple vCores: containers run in parallel across cores.
- Memory: 8–64 GB of DDR4 ECC, enough for full stacks.
- NVMe storage: fast image extraction and database volumes.
- Unmetered 1 Gbps port: image pulls and updates do not add bandwidth charges.
1. Set Resource Limits
services:
api:
image: registry.example.com/api:1.8.2
deploy:
resources:
limits: { cpus: "2.0", memory: 1g }
restart: unless-stopped
db:
image: postgres:16.4
shm_size: 256m
deploy:
resources:
limits: { memory: 4g }
volumes: [ "pgdata:/var/lib/postgresql/data" ]
restart: unless-stopped
volumes:
pgdata: {}
Recent Docker Compose versions apply deploy.resources.limits outside Swarm; check with docker stats that limits are in effect. Without limits, one leaking container can exhaust the server and trigger the kernel's out-of-memory killer on something important.
2. Publish Ports Carefully
Docker writes its own iptables rules, so a port published as "5432:5432" is reachable from the internet even if UFW blocks it. Publish internal services on localhost only, or not at all, and let containers talk over a Compose network:
ports:
- "127.0.0.1:8000:8000" # reachable only from the host (e.g. by Nginx)
Only the reverse proxy should listen publicly on 80 and 443.
3. One Reverse Proxy for TLS
Run Nginx on the host, or a containerised proxy such as Traefik or Caddy, to terminate HTTPS and route by domain to each container (see our reverse proxy guide). Containerised proxies can obtain certificates automatically from labels; host Nginx with Certbot is equally solid and easier to debug for many teams.
4. Image Hygiene
- Pin versions (
postgres:16.4, your app by commit SHA) rather thanlatest, so deploys are reproducible and rollbacks are possible. - Use small, maintained base images (official slim or distroless images).
- Rebuild regularly to pick up base-image security fixes, even when your code has not changed.
- Scan images for known vulnerabilities with a tool such as Trivy in CI.
- Do not bake secrets into images; pass them at runtime through environment files or Docker secrets.
5. Persistent Data and Backups
Containers are disposable; volumes are not. Keep every piece of persistent data on named volumes or bind mounts, and back them up properly:
# consistent database backup from a running container
docker compose exec -T db pg_dump -U app app | gzip > /var/backups/app-$(date +%F).sql.gz
# file volumes: archive from a temporary container
docker run --rm -v uploads:/data -v /var/backups:/backup alpine \
tar -czf /backup/uploads-$(date +%F).tgz -C /data .
Copy backups off the server and test restores. Copying a live database's data directory is not a safe backup; use the database's dump or backup tools.
6. Cap Logs
# /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": { "max-size": "20m", "max-file": "5" }
}
Restart Docker after changing it (new containers pick up the setting). Default logging has no size limit, and a chatty container can fill the disk over weeks.
7. Keep Disk Usage Under Control
docker system df
docker image prune -a --filter "until=168h" # unused images older than a week
docker builder prune --filter "until=168h"
Review what a prune will remove before running it on production, and never prune volumes unless you are certain they are unused.
8. Updates and Deploys
Deploy new versions by changing the image tag and running docker compose pull && docker compose up -d. Add health checks so Compose knows when a container is ready, and roll back by restoring the previous tag. CI can build, scan, push and deploy automatically (see our GitHub Actions guide). Keep the host OS and Docker Engine updated too.
9. Container Security Basics
- Run processes as a non-root user inside images (
USERin the Dockerfile). - Avoid
--privilegedand broad capabilities. - Do not mount the Docker socket into containers unless absolutely necessary; it grants root on the host.
- Use read-only filesystems where possible (
read_only: truewith tmpfs for writable paths). - Keep only the containers you need running.
Sizing a Container Host
| Stack | Typical memory | EPYC plan |
|---|---|---|
| App + PostgreSQL + Redis | 3–5 GB | 2 vCores / 8 GB |
| Above + workers + staging + monitoring | 8–12 GB | 4 vCores / 16 GB |
| Several products or many services | 16–28 GB | 8 vCores / 32 GB |
| Large stacks, search engines, analytics | 32 GB+ | 16 vCores / 64 GB |
Docker or Podman?
Podman runs containers without a central daemon and supports rootless containers well, with a Docker-compatible command line. Docker has the larger ecosystem and the familiar Compose workflow. Both run on an EPYC VPS; pick the one your team knows.
Health Checks and Startup Order
Add a healthcheck to services that others depend on, and use depends_on with condition: service_healthy so an application container waits for its database to accept connections rather than crashing on startup:
db:
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 10s
retries: 5
api:
depends_on:
db: { condition: service_healthy }
Health checks also make docker ps show which containers are actually working, not just running.
Monitoring Containers
Watch per-container CPU and memory with docker stats or cAdvisor feeding Prometheus, and alert on restarts and on containers approaching their memory limits.
Organising Compose Files
Keep one Compose project per application in its own directory with its own .env file, and use an override file for staging differences rather than copying the whole file. Name projects explicitly so container and volume names stay predictable across servers.
SkyRainCloud Plans for This Workload
Container stacks are sized by the sum of their memory: a small Compose stack fits on 2 vCores / 8 GB, a full product with database, cache, workers and monitoring on 4–8 vCores and 16–32 GB. NVMe storage keeps image pulls and database volumes fast.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.