Docker Compose Memory Limits Calculator

Docker Compose's deploy.resources block controls how much memory a service reserves and how much it's allowed to use before it gets killed. This calculator sizes both values — plus the service-level mem_limit / mem_reservation equivalent — from your service's observed average and peak memory usage.

01 Usage data

Enter observed usage directly, in MiB.

02 Workload profile

Advanced: margins and defaults

Values the result relies on that are our own defaults, or vendor defaults your setup may change. Each “?” says how one moves the result; the guide says where it comes from.

03 Sizing gauge

0 —

04 docker-compose.yml

—

05 How this was derived

Enter usage data to see the calculation.

Limits, reservations and swap in short

The limit becomes the container's hard memory limit (--memory). The reservation becomes --memory-reservation: a soft limit, lower than the limit, that Docker enforces only when it detects contention or low memory on the host. Docker docs

The calculator sizes the reservation from the average and the limit from the peak, then adds margins that are MemoryLimit's own defaults, not vendor figures; you can change them under Advanced. Docker rejects a limit below its reservation, so when the peak is close to the average the limit is raised to the reservation. Docker source

Swap. If the host has swap and memswap_limit isn't set, a container with a memory limit can use as much swap as that limit. Setting memswap_limit equal to the limit prevents any swap. The calculator leaves swap as Docker sets it. Docker docs

Common input mistakes

  • Sizing from total usage instead of the working set: total usage includes reclaimable file cache, so services that read many files get larger values.
  • Filtering by the wrong container name: Compose names containers <project>-<service>-<number>, and a service with its own container_name needs that name in the query.
  • A window that misses the busiest times: the limit comes out too low.

Full derivation, warnings and every assumption: how the Docker Compose calculator works. The shared formula and margin tables: the sizing model.

Related calculators: