Running Docker Compose comfortably on a small server
27 Nov 2026 docker performance
Memory limits, logs, images and builds: the four things that sink small Docker hosts.
Docker runs well on a small server if you decide the limits instead of discovering them.
Set memory limits
Without limits one container can starve the others and the system.
services:
app:
mem_limit: 300m
db:
mem_limit: 400m
Keep the sum comfortably below the server's memory.
Cap logs
Container logs grow without end by default.
{ "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "3" } }
Clean up images
Each update leaves the old image behind. docker image prune -f after a successful deployment is usually enough. Check with docker system df.
Build elsewhere
Compiling assets can need far more memory than running the result. Build in your pipeline and pull finished images, or add swap and accept slow builds on a hard disk.
Watch published ports
A published port is reachable even if your ufw rules suggest otherwise. Publish databases to 127.0.0.1 or not at all.
Health checks
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 10s
retries: 5
Know when to stop
Containers add overhead. For one small application, a plain systemd service may be simpler.