Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Docker Compose on a 1 GiB VPS: what actually fits, and how to keep it up

说明与用途

在 1 GiB VPS 上,Docker Compose 可以通过安装官方 Docker Engine、添加 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