Running Multi-Container Production Stacks on a 1GB Ubuntu 24.04 VPS Without Swap Thrashing
INTTECH Cloud Operations — November 2026
How to configure Docker memory ceilings, Alpine Linux base images, Nginx reverse proxies, and MariaDB buffer pools to host multiple web platforms on minimal cloud hardware.
1. Right-Sizing Container Base Images
Standard Ubuntu or Node Docker images consume hundreds of megabytes of disk and carry unnecessary background services. Switching frontend delivery containers to nginx:alpine reduces runtime RAM consumption to roughly 12–16 MB per container, leaving valuable headroom for backend APIs and relational databases.
2. Enforcing Hard Memory Limits & ZRAM Compression
In docker-compose.yml, defining deploy.resources.limits.memory prevents a single runaway process from starving the host kernel. Pairing container memory limits with compressed swap (zram) and tuned vm.swappiness ensures graceful degradation during sudden traffic bursts.
3. Unified Nginx Reverse Proxy & SSL Termination
Instead of exposing multiple application ports publicly, binding each container to 127.0.0.1 on dedicated loopback ports and routing traffic through a host Nginx reverse proxy centralizes TLS termination, Gzip compression, and HTTP/2 multiplexing across all subdomains.