Docker Compose on a 1 GiB VPS: what actually fits, and how to keep it up
Описание и применение
На VPS с 1 ГБ оперативной памяти Docker Compose можно стабильно запустить, если установить официальную сборку Docker, добавить swap, задать лимиты памяти и лог‑ротацию, а также закрепить версии образов. При наличии выделенного IPv4 можно использовать Caddy для HTTPS.
Задача
Running Docker Compose on a 1 GiB VPS leads to OOM kills and disk exhaustion because containers lack memory limits, swap, log rotation, and image pinning.
Результат
The VPS runs Docker Compose reliably: containers stay within memory limits, swap prevents abrupt OOM kills, logs stay bounded, and images are reproducible. Reverse proxy works only with a dedicated IPv4 or is omitted for non‑browser services.
Рабочий процесс
- Install Docker Engine from official repo and docker‑compose‑plugin
- Add current user to docker group and start new shell
- Create 2 GiB swapfile and set vm.swappiness=10
- Configure /etc/docker/daemon.json with log‑driver limits
- Restart docker daemon and recreate containers
- Add mem_limit and memswap_limit to each service in compose file
- Pin image tags (or digests) in compose file
- If needed, obtain dedicated IPv4 or skip reverse proxy
Доказательства
Docker itself is not the problem on a 1 GiB box — the daemon idles under 50 MB.
Add a swap file before you add containers
Give every service a memory limit
Log rotation, or the disk fills quietly
- Дата записи: 2026-09-21T01:15:28.223Z