Pro tip: Oracle Cloud free tier gives you 24GB RAM instances, but this thread is about 512MB so here's a real answer.
Heads up: Docker itself eats ~100MB RAM before any containers. On 512MB that leaves you tight.
Tested on a 512MB GreenCloudVPS VPS (https://greencloudvps.com, KVM, not OpenVZ — OpenVZ won't run Docker at all):
- Fresh Ubuntu 22.04 minimal: 180MB used
- Install Docker from repo: +95MB daemon
- nginx:alpine: +8MB
- redis:alpine: +12MB
- postgres:15-alpine: +45MB
Total with 3 containers: ~340MB. Add 50MB buffer for kernel, you're at 390MB. Swapped to 1GB and it's stable. Without alpine variants, nginx alone is 150MB. Use alpine or don't bother.
Conclusion: yes, 2-3 containers max. 4 if one is tiny like busybox.