TB-401 — Support a memory burst allowance on containers end-to-end
Type: feature · Workspace ticket (spans: moby, cli, compose)
Summary
Add a memory burst allowance to container configuration: a new Engine API Resources
field, a docker run/docker create flag, and a docker compose up flag applying it to
all created containers. The value is validated by a single shared helper exported from the
docker CLI, so both CLIs reject the same inputs for the same reason.
Description
Operators want an advisory burst allowance alongside the existing hard Memory limit: a
byte figure recording how far above the limit a container may briefly go, for monitoring
and scheduling tooling to read back. This ticket covers plumbing the value end-to-end from
both CLIs to the Engine API type; engine-side enforcement is out of scope (the field is
carried, stored, and echoed back on inspect — semantics mirror MemoryReservation's
transport, not its enforcement).
The validation rule is shared rather than duplicated. A burst allowance only means
something relative to the limit it bursts above, so the check ("unset, or strictly greater
than Memory") has to be identical on both CLIs. The docker CLI owns it and exports it;
compose consumes that exported surface rather than reimplementing the rule. This is
deliberate: a rule reimplemented twice is a rule that drifts.
Targets: the moby Engine API + Go client (transport only), the docker CLI, and the
docker compose CLI.
Acceptance criteria
moby
Resources (package github.com/moby/moby/api/types/container, embedded in
container.HostConfig) gains the field MemoryBurst int64, declared next to
MemoryReservation, with the doc comment:
Memory burst allowance (in bytes); 0 means unset.
The field round-trips JSON marshal/unmarshal under the name MemoryBurst.
cli
- Package
github.com/docker/cli/opts gains the exported function
ValidateMemoryBurst(burst, limit int64) error, following the package's existing
ValidateXxx convention. It returns nil when burst == 0 (unset) or when
burst > limit, and otherwise returns an error whose message is exactly:
memory burst must be greater than the memory limit
Unit-tested in opts for: unset, burst above limit, burst equal to limit, burst below
limit, and burst set while limit is 0.
docker run --memory-burst 512m <image> produces a container-create request whose
HostConfig.MemoryBurst equals 536870912 (unit test at the container-options level,
mirroring the existing --memory-reservation coverage). The flag is typed
opts.MemBytes, so it accepts the same human-readable suffixes as --memory.
docker run --help lists --memory-burst with the help text exactly:
Memory burst allowance above the memory limit
docker run --memory 256m --memory-burst 128m <image> fails before any API call, with
the error from criterion 2.
compose
docker compose up --memory-burst 512m applies MemoryBurst = 536870912 to the
HostConfig of every container it creates (unit test at the service-convert/create
level, mirroring the existing memory-limit mapping coverage).
docker compose up --help lists --memory-burst with the help text exactly:
Memory burst allowance above the memory limit for all created containers
- compose rejects an invalid pairing by calling
opts.ValidateMemoryBurst — not by
reimplementing the comparison — and surfaces that function's error message unchanged.
Consumed surfaces (per dependency edge)
- cli → moby: the field
MemoryBurst int64 on container.Resources
(module github.com/moby/moby/api, package .../api/types/container); value semantics:
0 = unset, positive = the burst allowance in bytes.
- compose → moby: the same field,
MemoryBurst int64 on container.Resources, same
semantics, set via the container-create request compose issues per service.
- compose → cli: the function
ValidateMemoryBurst(burst, limit int64) error,
exported from module github.com/docker/cli, package github.com/docker/cli/opts.
compose already imports this package (cmd/compose/build.go uses cliopts.MemBytes),
so the surface is consumed through an existing edge, not a new one.
Verification
Local only — this workspace has no Docker engine and CI is disabled on the origins. No
step may contact a live daemon.
- Build: each member compiles after its change, with the workspace linkage rules in
AGENTS.md applied.
- Unit tests: the packages touched by criteria 1, 2, 3, 6 and 8.
- Parse/help surfaces: criteria 4 and 7 are checked by running the command's
--help
and reading the flag line; criteria 5 and 8 by the failure path returning before any
client call.
Links
- Tech spec: none — this ticket is self-contained.
- Design: none (CLI-only surface).
- Dependencies: none.