dockermem

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dockermem measures the memory a stack has to fit into, and what is already in it.

Declared limits are useless for this: one my-app stack declares more than 13 GB of mem_limit across its services yet runs in about 2 GB, because mem_limit is a ceiling and not a reservation. Only measurement tells you whether one more stack fits.

Where that memory lives decides what counts as used. Docker Desktop holds a budget of its own, so the containers are all of it; a native Linux docker shares the machine with the user's session, so the desktop and the browser count too. See Usage.Shared.

Index

Constants

View Source
const WarnRatio = 0.85

WarnRatio is the share of the available memory above which starting one more stack is worth a warning.

Variables

This section is empty.

Functions

func Human

func Human(n int64) string

func ParseSize

func ParseSize(s string) (int64, error)

ParseSize reads the sizes docker stats prints, e.g. "334.2MiB", "1.47GiB".

Types

type Usage

type Usage struct {
	Total int64 // bytes the containers have to fit into
	Used  int64 // bytes already used, by the containers alone unless Shared
	// StackUsed excludes one-off `compose run` containers: a migration
	// container peaking at 6 GB is not what a stack costs, and counting it
	// would triple the estimate.
	StackUsed int64
	Projects  int // distinct compose projects, one-offs excluded
	// Shared says the daemon runs on the very machine wtm does, which is a
	// native Linux docker. There the containers compete with the user's own
	// session for one pool of RAM, so Used is what the whole machine uses and
	// not the sum of the containers: a desktop holding 6 GB is pressure the
	// containers cannot see, and ignoring it made the warning fire long after
	// the machine had started to thrash. Docker Desktop, on macOS or through
	// WSL2, gives the containers a budget of their own, where that sum IS the
	// pressure.
	Shared bool
}

func Read

func Read(ctx context.Context, runner execx.Runner) (Usage, error)

func (Usage) PerProject

func (u Usage) PerProject() int64

PerProject is the average cost of a running stack, the best available estimate of what one more would cost.

func (Usage) Projected

func (u Usage) Projected() int64

func (Usage) Tight

func (u Usage) Tight() bool

func (Usage) Warning

func (u Usage) Warning() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL